Repository navigation
63 lines (60 loc) · 2.75 KB
/
Copy pathsync.yml
File metadata and controls
63 lines (60 loc) · 2.75 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
# Twice a day: pull pages edited on the BI wiki since the last run, re-parse them and commit the result.
# The code lives in a3ref/a3ref.github.io; that repository deploys the site once this data changes.
# GitHub may delay or drop scheduled runs under load, so there are two; a sync with no wiki edits commits nothing.
# Those runs read only the wiki's recent changes; once a week a walk lists every member page, which also catches
# pages that join or leave a category through a template. Every sync also updates raw/templates.json, the wiki
# templates the pages transclude: the build renders the pages with them (through the MediaWiki parser port).
name: Sync from wiki
on:
schedule:
- cron: "17 4 * * *"
- cron: "17 16 * * *"
- cron: "17 10 * * 0" # the weekly walk; keep in step with the sync step below
workflow_dispatch:
inputs:
full:
description: "Re-download every page instead of only the changed ones"
type: boolean
default: false
walk:
description: "List every member page instead of reading only the wiki's recent changes"
type: boolean
default: false
concurrency:
group: sync
cancel-in-progress: false
jobs:
sync:
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/checkout@v7
- uses: actions/checkout@v7
with:
repository: a3ref/a3ref.github.io
path: .tool
- uses: actions/setup-python@v7
with:
python-version: "3.12"
cache: pip
cache-dependency-path: .tool/requirements.txt
- run: pip install -r .tool/requirements.txt
- run: sudo apt-get install -y xvfb
# The wiki is behind a Cloudflare challenge: run the real Chrome preinstalled on the runner in a virtual display.
- working-directory: .tool
run: xvfb-run --auto-servernum python -m biwiki --raw "$GITHUB_WORKSPACE/raw" sync ${{ inputs.full && '--full' || '' }} ${{ (inputs.walk || github.event.schedule == '17 10 * * 0') && '--walk' || '' }}
# The JSON is all this build is for: no preview images (the site's own deploy draws them).
- working-directory: .tool
run: python -m biwiki --raw "$GITHUB_WORKSPACE/raw" --dataset "$GITHUB_WORKSPACE" --out "$RUNNER_TEMP/out" build --no-og-images
- run: |
git add raw commands.json functions.json topics.json index.json syntax.json schema.json
if git diff --cached --quiet; then
echo "No changes on the wiki."
exit 0
fi
git config user.name "github-actions[bot]"
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
git commit -m "Sync from BI wiki $(date -u +%F)"
git pull --rebase origin main
git push