Skip to content

Commit 44af260

Browse files
committed
docs: enhance TOC generation workflow to trigger on push events
1 parent 9bc4e72 commit 44af260

File tree

1 file changed

+36
-3
lines changed

1 file changed

+36
-3
lines changed

.github/workflows/build-toc.yaml

+36-3
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,48 @@
1-
name: Generate TOC on PR Merge
1+
name: Generate TOC on PR Merge or Push
22

33
on:
4+
# Trigger on PR merge
45
pull_request_target:
56
types:
67
- closed
78
branches:
89
- main
10+
# Trigger on direct pushes to main branch
11+
push:
12+
branches:
13+
- main
914

1015
jobs:
11-
if_merged:
12-
if: github.event.pull_request.merged == true
16+
build_toc_on_pr_merge:
17+
if: github.event_name == 'pull_request_target' && github.event.pull_request.merged == true
18+
runs-on: ubuntu-latest
19+
steps:
20+
- name: Checkout repository
21+
uses: actions/checkout@v3
22+
23+
- name: Set up Python 3
24+
uses: actions/setup-python@v3
25+
with:
26+
python-version: '3.x'
27+
28+
- name: Run TOC generation script
29+
run: |
30+
chmod +x .scripts/idxtool.py
31+
python3 .scripts/idxtool.py --toc
32+
33+
- name: Commit TOC updates
34+
run: |
35+
git config --global user.name 'LouisShark'
36+
git config --global user.email '[email protected]'
37+
git add .
38+
git commit -m "docs: Update TOC.md" || echo "No changes to commit"
39+
git pull --rebase
40+
git push origin HEAD:main
41+
env:
42+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
43+
44+
build_toc_on_push:
45+
if: github.event_name == 'push'
1346
runs-on: ubuntu-latest
1447
steps:
1548
- name: Checkout repository

0 commit comments

Comments
 (0)