-
Notifications
You must be signed in to change notification settings - Fork 0
97 lines (84 loc) · 2.66 KB
/
Copy pathbuild-content.yml
File metadata and controls
97 lines (84 loc) · 2.66 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
name: Build Content Pages
on:
push:
branches:
- main
paths:
- 'data/**'
- 'templates/**'
- 'scripts/**'
- 'tests/**'
- 'documents/JRM_CV.tex'
- 'requirements-build.txt'
- 'ruff.toml'
- 'mypy.ini'
- '.github/workflows/build-content.yml'
pull_request:
branches:
- main
paths:
- 'data/**'
- 'templates/**'
- 'scripts/**'
- 'tests/**'
- 'documents/JRM_CV.tex'
- 'requirements-build.txt'
- 'ruff.toml'
- 'mypy.ini'
- '.github/workflows/build-content.yml'
workflow_dispatch: # Allow manual triggering
# Both build workflows commit and push to main, and a push touching
# documents/JRM_CV.tex starts both at once. Serialize them so the second
# one cannot be rejected as non-fast-forward.
concurrency:
group: main-autocommit
cancel-in-progress: false
jobs:
validate-and-build:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v5
with:
submodules: true
- name: Set up Python
uses: actions/setup-python@v6
with:
python-version: '3.11'
cache: 'pip'
cache-dependency-path: 'requirements-build.txt'
- name: Install dependencies
run: pip install -r requirements-build.txt
# Lint and type-check before running any of it: a script that fails these
# is a script we should not be building the site with. Both read their
# config from ruff.toml / mypy.ini, so these commands match what a
# contributor runs locally.
- name: Lint (ruff)
run: ruff check
- name: Type check (mypy)
run: mypy
- name: Validate data files
working-directory: scripts
run: python validate_data.py
- name: Build HTML pages
working-directory: scripts
run: python build.py
- name: Run tests
run: python -m pytest tests/ -v
- name: Check for changes
id: check_changes
run: |
if [[ -n $(git status --porcelain *.html) ]]; then
echo "changes=true" >> $GITHUB_OUTPUT
else
echo "changes=false" >> $GITHUB_OUTPUT
fi
- name: Commit and push changes
if: github.event_name == 'push' && steps.check_changes.outputs.changes == 'true'
run: |
git config user.name 'github-actions[bot]'
git config user.email 'github-actions[bot]@users.noreply.github.com'
git add publications.html people.html software.html news.html
git commit -m "Auto-build: Update content pages from spreadsheet data"
git pull --rebase
git push