Repository navigation
103 lines (98 loc) · 3.97 KB
/
Copy pathsite.yml
File metadata and controls
103 lines (98 loc) · 3.97 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
98
99
100
101
102
103
# Builds the site from the latest a3ref/data and deploys it to GitHub Pages.
# Runs on every push here, and every hour, deploying only if the data changed: the site follows a data sync
# (scheduled or run by hand) within the hour, as a3ref/data cannot start this workflow without a token.
# Scheduled runs are best-effort on GitHub (they can be delayed or dropped); the check costs seconds.
# The watchdog (every 6 hours) fails, and GitHub emails, when the data sync has not run for more than 26 hours.
name: Deploy site
on:
schedule:
- cron: "47 * * * *"
- cron: "53 */6 * * *" # watchdog
push:
branches: [main]
workflow_dispatch:
concurrency:
group: site
cancel-in-progress: false
jobs:
watchdog:
if: github.event.schedule == '53 */6 * * *'
runs-on: ubuntu-latest
steps:
- env:
GH_TOKEN: ${{ github.token }}
run: |
last=$(gh api "repos/a3ref/data/actions/workflows/sync.yml/runs?status=success&per_page=1" --jq '.workflow_runs[0].created_at')
age=$(( ($(date +%s) - $(date -d "$last" +%s)) / 3600 ))
echo "last successful data sync: $last ($age hours ago)"
if [ "$age" -gt 26 ]; then
echo "::error title=Data sync is late::The last successful sync in a3ref/data ran $age hours ago. Check its Actions tab, or run it by hand."
exit 1
fi
check:
if: github.event.schedule != '53 */6 * * *'
runs-on: ubuntu-latest
outputs:
deploy: ${{ steps.compare.outputs.deploy }}
steps:
- id: compare
run: |
latest=$(git ls-remote https://github.com/a3ref/data.git refs/heads/main | cut -f1)
live=$(curl -fsSL https://wiki.arma3.io/data-version.txt || true)
echo "data: $latest, live site: ${live:-none}"
if [ "$GITHUB_EVENT_NAME" != "schedule" ] || [ "$latest" != "$live" ]; then
echo "deploy=true" >> "$GITHUB_OUTPUT"
else
echo "deploy=false" >> "$GITHUB_OUTPUT"
fi
deploy:
needs: check
if: needs.check.outputs.deploy == 'true'
runs-on: ubuntu-latest
permissions:
contents: read
pages: write
id-token: write
issues: write
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
steps:
- uses: actions/checkout@v7
- uses: actions/checkout@v7
with:
repository: a3ref/data
path: data
fetch-depth: 0 # the history is the change feed
- uses: actions/setup-python@v7
with:
python-version: "3.12"
cache: pip
- run: pip install -r requirements.txt
# the live sitemap, before this deploy replaces it: IndexNow gets the pages that differ from it
- run: curl -fsSL https://wiki.arma3.io/sitemap.xml -o previous-sitemap.xml || true
- run: python -m unittest # parser and build tests on tests/fixtures, a few seconds
- id: build
run: python -m biwiki build
- run: python -m biwiki feed
- run: git -C data rev-parse HEAD > out/data-version.txt
- uses: actions/upload-pages-artifact@v5
with:
path: out
- id: deployment
uses: actions/deploy-pages@v5
# After deploying, so the engines find the pages and the key file live. A refused list does not fail the
# deploy; the step shows as failed in the run.
- name: IndexNow
if: always() && steps.deployment.outcome == 'success'
continue-on-error: true
run: python -m biwiki indexnow --previous previous-sitemap.xml
# After deploying, so one broken page never blocks the rest of the site.
# New problems (not in known-problems.json) open/update the "parser-report" issue;
# a page the parser crashed on also fails this run, which sends an email.
- name: Parser report
if: always() && steps.build.outcome == 'success'
env:
GH_TOKEN: ${{ github.token }}
GH_REPO: ${{ github.repository }}
run: python -m biwiki report --issue