Skip to content

Installation

Justin Forest edited this page Aug 5, 2024 · 3 revisions

This repository is intended to be used as a GitHub Action, invoked whenever a GitHub wiki page is updated. The code consists of two separate Python scripts, one for TOC, the other for backlinks. To use this code in your repository, add a GitHub workflow like this:

# This is an example of a workflow file that updates wiki pages.
# You put this file in the .github/workflows directory of your repository,
# e.g. `.github/workflows/update-wiki.yml`.
#
# The script should be in the `bin` directory at the root of your wiki repository,
# please use `git` from CLI to add it.
#
# Note that you might need to go to your repository settings and enable using all actions,
# not only from your organization, if you are using a private repository in an organization.

name: Update wiki pages

on:
  # This means that the workflow runs on all wiki updates.
  gollum:
  # This lets you run the workflow manually from the Actions tab.
  workflow_dispatch:

jobs:
  update:
    runs-on: ubuntu-latest
    steps:
      - name: Checkout wiki
        uses: actions/checkout@v4
        with:
          repository: ${{github.repository}}.wiki
          path: wiki

      - name: Update tables of contents
        uses: umonkey/[email protected]
        with:
          path: wiki
          toc_header: "**Table of Contents:**"
          backlinks_header: "## Pages that link here"

      - name: Commit changes
        uses: stefanzweifel/git-auto-commit-action@v4
        with:
          commit_message: Github Actions - Wiki helpers

Then, whenever you edit a wiki page, the scripts run and update your TOC and backlinks sections in all pages where you added the placeholders.

Clone this wiki locally