-
Notifications
You must be signed in to change notification settings - Fork 4
69 lines (54 loc) · 2.04 KB
/
Copy pathupdate_breadcrumbs.yml
File metadata and controls
69 lines (54 loc) · 2.04 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
name: Update breadcrumbs on mkdocs.yml change (GitHub App)
on:
push:
branches:
- main
- dev
paths:
- 'mkdocs.yml'
permissions:
contents: write
jobs:
update-breadcrumbs:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
persist-credentials: false
- name: Generate GitHub App installation token
id: app-token
uses: tibdex/github-app-token@v2
with:
app_id: ${{ secrets.PURDUERCAC_DOCS_BOT_APP_ID }}
private_key: ${{ secrets.PURDUERCAC_DOCS_BOT_PRIVATE_KEY }}
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.x'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install pyyaml
- name: Configure git identity
run: |
git config user.name "purduercac-docs-bot"
git config user.email "purduercac-docs-bot@users.noreply.github.com"
git pull
- name: Generate breadcrumbs
run: python tools/generate_breadcrumbs.py
- name: Commit and push updated breadcrumbs (using App token)
env:
GITHUB_APP_TOKEN: ${{ steps.app-token.outputs.token }}
run: |
# Stage the regenerated JSON before pulling
git add docs/assets/data/breadcrumbs.json || true
# Sync with branch to avoid rebase errors
git pull origin ${{ github.ref_name }} --rebase || git pull origin ${{ github.ref_name }}
# Re-stage in case of merge/rebase updates
git add docs/assets/data/breadcrumbs.json || true
# Skip commit if no changes
git diff --cached --quiet && echo "No changes to commit" && exit 0
git commit -m "Auto-update breadcrumbs.json after mkdocs.yml change"
git push https://x-access-token:${GITHUB_APP_TOKEN}@github.com/${{ github.repository }} HEAD:${{ github.ref_name }}