Add workflow to auto-update README table of contents #1
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
on: | |
push: | |
paths: [ 'README.md' ] | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
permissions: | |
contents: write | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
fetch-depth: 2 | |
- run: | | |
curl https://raw.githubusercontent.com/ekalinin/github-markdown-toc/master/gh-md-toc -o gh-md-toc | |
chmod a+x gh-md-toc | |
./gh-md-toc --insert --no-backup --hide-footer README.md | |
rm gh-md-toc | |
- name: Get last commit message | |
id: last-commit | |
run: | | |
echo "message=$(git log -1 --pretty=%s)" >> $GITHUB_OUTPUT | |
echo "author=$(git log -1 --pretty=\"%an <%ae>\")" >> $GITHUB_OUTPUT | |
- uses: stefanzweifel/git-auto-commit-action@v5 | |
with: | |
commit_author: ${{ steps.last-commit.outputs.author }} | |
commit_message: ${{ steps.last-commit.outputs.message }} | |
commit_options: '--amend --no-edit' | |
push_options: '--force' | |
skip_fetch: true |