ekalinin / github-markdown-toc

Easy TOC creation for GitHub README.md

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Automated markdown TOC generation with Github Actions

banzo opened this issue · comments

Would it be possible to make this tool available trough GitHub Actions? This way when someone pushes markdown files, the action would generate the TOC and commit back the updated version of the markdown files.

Note: Maybe this project could be used to commit the updated markdown https://github.com/stefanzweifel/git-auto-commit-action

This is easy, and actually I do.

on:
  push:
    branches: [main]
    paths: ['foo.md']

jobs:
  build:
    runs-on: ubuntu-latest
    timeout-minutes: 5
    steps:
      - uses: actions/checkout@v2
      - 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 foo.md
      - uses: stefanzweifel/git-auto-commit-action@v4
        with:
          commit_message: Auto update markdown TOC

(my real example is https://github.com/sensuikan1973/othello-complete-analysis/blob/main/.github/workflows/update_toc.yaml.)

Thanks for the example, @sensuikan1973 !
Do you mind if I add it into README?

sure👍