From 1606e4e4b0faa4fb168565db1d4bf942bc299a97 Mon Sep 17 00:00:00 2001 From: Kevin Deldycke Date: Mon, 3 Aug 2020 14:39:28 +0200 Subject: [PATCH] Auto-generate TOC. --- .github/workflows/autofix.yaml | 38 ++++++++++++++++++++++++++++++++++ readme.md | 4 ++++ 2 files changed, 42 insertions(+) create mode 100644 .github/workflows/autofix.yaml diff --git a/.github/workflows/autofix.yaml b/.github/workflows/autofix.yaml new file mode 100644 index 0000000..ed62312 --- /dev/null +++ b/.github/workflows/autofix.yaml @@ -0,0 +1,38 @@ +name: Autofix +on: + push: + # Only targets master default branch to avoid amplification effects of + # auto-fixing the exact same stuff in multiple non-rebased branches. + branches: + - 'master' + schedule: + # Run linter every week to catch regressions from external dependencies. + - cron: 17 9 * * 1 + +jobs: + + toc: + name: Generator TOC and auto-commit + runs-on: ubuntu-latest + steps: + - name: Install doctoc + run: | + sudo npm install -g doctoc + - uses: actions/checkout@v2.3.1 + - name: Generate full TOC + run: | + # Generates title as part of the TOC to avoid extra non-conform blank + # lines. See: + # https://github.com/thlorenz/doctoc/issues/101 + # https://github.com/thlorenz/doctoc/pull/145 + doctoc --github --title "## Contents" readme.md + - name: Remove blacklisted TOC entries + # See: https://github.com/sindresorhus/awesome-lint/blob/v0.13.0/rules/toc.js#L15-L20 + run: | + gawk -i inplace '!/^- \[(Contribute|Contributing|Licence|License)\]\(#.+\)$/{print}' ./readme.md + - name: Commit and push changes + uses: stefanzweifel/git-auto-commit-action@v4.4.0 + with: + commit_author: "Kevin Deldycke " + commit_message: "[lint] Update TOC." + file_pattern: readme.md diff --git a/readme.md b/readme.md index fab8581..5341d9d 100644 --- a/readme.md +++ b/readme.md @@ -23,6 +23,8 @@ subtleties. In a sense, *Falsehood* articles are a suite of wordy unit-tests covering extensive edge-cases provided by real-world usage. + + ## Contents @@ -45,6 +47,8 @@ extensive edge-cases provided by real-world usage. - [Software Engineering](#software-engineering) - [Typography](#typography) + + ## Meta