-
-
Notifications
You must be signed in to change notification settings - Fork 6.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
40 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
name: Generate table of contents | ||
|
||
on: | ||
pull_request: | ||
push: | ||
branches: | ||
- master | ||
|
||
env: | ||
BRANCH_NAME: ${{ github.head_ref || github.ref_name }} | ||
|
||
jobs: | ||
gen-toc: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v3 | ||
with: | ||
ref: ${{ github.head_ref }} | ||
- name: Install dependencies | ||
run: npm install | ||
- name: Generate table of contents | ||
run: npm run gen | ||
- name: 'Commit changes if required' | ||
run: | | ||
if ! git diff --quiet README.md; then | ||
git config user.email "github-actions[bot]@users.noreply.github.com" | ||
git config user.name "GitHub Actions" | ||
git add README.md | ||
git commit -m "[auto] regenerate table of contents" | ||
git push | ||
echo "[info] Table of contents updated and committed." | ||
else | ||
echo "[info] No changes to table of contents." | ||
fi | ||
working-directory: ${{ github.workspace }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters