Generate Wiki tables of contents #315
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
name: "Generate Wiki tables of contents" | |
on: | |
- gollum | |
- workflow_dispatch | |
jobs: | |
"generate-toc": | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
with: | |
repository: ${{ github.repository }}.wiki | |
token: ${{ secrets.WIKI_UPDATE_TOC_TOKEN }} | |
- run: | | |
curl -O https://raw.githubusercontent.com/ekalinin/github-markdown-toc/17ec0170cdb8ac5c6fc4aa265087a1067e930b0a/gh-md-toc | |
chmod +x gh-md-toc | |
# Avoid recursive Actions invocations. | |
if git show -s --format='%B' | egrep '^Updated '; then | |
# Make sure to insert tables of contents individually, so that they | |
# don't include the name of the document in the item links. | |
for i in $(grep -l '<!--ts-->' *.md); do ./gh-md-toc --insert --no-backup "$i"; done | |
fi | |
- name: Remove timestamps | |
uses: jacobtomlinson/gha-find-replace@v3 | |
with: | |
find: "<!-- Added by: runner, at: [^-]+ -->" | |
replace: "<!-- Added by: runner, at: (timestamp removed) -->" | |
include: "*.md" | |
regex: true | |
- uses: stefanzweifel/git-auto-commit-action@v4 | |
with: | |
commit_message: Auto update Wiki tables of contents | |
file_pattern: "*.md" |