name: Table of contents

on:
  push:
    branches: [ main, master ]
    paths: [ 'README.md' ]

jobs:
  build:
    runs-on: ubuntu-latest
    timeout-minutes: 5
    steps:
      - uses: actions/checkout@v2
      - run: |
          FILE=gh-md-toc
          [[ -f "$FILE" ]] || curl https://raw.githubusercontent.com/ekalinin/github-markdown-toc/master/gh-md-toc -o $FILE
          chmod a+x $FILE
          ./$FILE --insert --no-backup README.md
      - uses: stefanzweifel/git-auto-commit-action@v4
        with:
          commit_message: Auto update markdown TOC
