-
Notifications
You must be signed in to change notification settings - Fork 2
72 lines (62 loc) · 2.24 KB
/
Copy pathapi-map.yml
File metadata and controls
72 lines (62 loc) · 2.24 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
name: Generate API map
on:
schedule:
# Weekly refresh — API-map.yaml files change far less often than commits.
- cron: "20 4 * * 1"
workflow_dispatch: {}
permissions:
contents: write
# Two runs committing to the same branch would race on push.
concurrency:
group: api-map
cancel-in-progress: false
jobs:
generate:
runs-on: ubuntu-latest
timeout-minutes: 20
steps:
- name: Checkout
uses: actions/checkout@v4
with:
persist-credentials: true
fetch-depth: 0
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: "20"
cache: "npm"
cache-dependency-path: web2/package-lock.json
# The generator parses API-map.yaml with js-yaml, a dependency of web2.
- name: Install dependencies
working-directory: web2
run: npm ci
# Shared with the monthly-updates generator, which also reads this repo.
- name: Cache physlib clone
uses: actions/cache@v4
with:
path: web2/.cache/physlib.git
key: physlib-clone-${{ github.run_id }}
restore-keys: physlib-clone-
- name: Run generator
working-directory: web2
run: node scripts/generate-api-map.js
- name: Commit & push updated API map
id: commit
run: |
git config user.name "github-actions[bot]"
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
git add web2/data/APIMap.json
if git diff --cached --quiet; then
echo "No API map changes to commit."
echo "committed=false" >> "$GITHUB_OUTPUT"
exit 0
fi
git commit -m "chore(api-map): auto-generated update"
git pull --rebase --autostash origin "${GITHUB_REF_NAME}"
git push origin "HEAD:${GITHUB_REF_NAME}"
echo "committed=true" >> "$GITHUB_OUTPUT"
# The site deploys via Gabrielebattimelli/Physlib-Website (Vercel).
# mirror-to-personal.yml keeps that mirror in sync, including for the
# commit just pushed above: it also runs on workflow_run for this
# workflow, which (unlike `push`) fires regardless of which token made
# the commit it's mirroring.