spenserblack / actions-wiki

:open_book: Deploy docs from your source tree to a GitHub wiki
https://github.com/marketplace/actions/wiki-update
MIT License
9 stars 3 forks source link
action actions github github-actions github-wiki wiki

Publish to GitHub wiki action

CI Dogfood Test Check dist/ codecov

๐Ÿ“– Deploy docs from your source tree to the GitHub wiki

![](https://user-images.githubusercontent.com/61068799/231881220-2915f956-dbdb-4eee-8807-4eba9537523f.png)

๐ŸŒ Works across repositories (with a PAT) \ ๐Ÿ“š Pretty interface for Markdown docs \ โคด๏ธ Lets you open PRs for wiki docs \ ๐Ÿ’ป Supports runs-on: windows-*

Usage

GitHub Actions GitHub wiki

Getting started is easy! Just create a GitHub Actions workflow file that uses spenserblack/actions-wiki and you're good to go! ๐Ÿš€ Here's a ready-made example to help you blast off:

name: Publish wiki
on:
  push:
    branches: [main]
    paths: [wiki/**, .github/workflows/publish-wiki.yml]
concurrency:
  group: wiki
  cancel-in-progress: true
permissions:
  contents: write
jobs:
  wiki:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v3
      - uses: spenserblack/actions-wiki@<version>
        with:
          # Whatever directory you choose will be mirrored to the GitHub
          # .wiki.git. The default is .github/wiki.
          path: wiki
Screenshot of 'Create the first page' button

โ— Make sure you turn on the GitHub wiki feature in your repo's settings menu. You'll also need to manually create a dummy page to initialize the git repo that powers the GitHub wiki. If you don't, when we push to your-repo.wiki.git, your workflow will fail because the wiki doesn't exist.

โš ๏ธ You'll need to remember to enable the contents: write permission! GitHub recently changed the default permissions granted to jobs for new repositories.

Publishing to a different repository

If you're pushing to a wiki that's not the current repository you'll need to get a GitHub PAT to push to it. The default ${{ secrets.GITHUB_TOKEN }} won't cut it! You can generate a PAT in your GitHub Settings.

For example, if you created octocat/gigantic-mega-project-wiki to hold the wiki and you want to publish it to the GitHub wiki that belongs to another repository like octocat/gigantic-mega-project, you'd use a step like this in one of your GitHub Actions workflows.

- uses: spenserblack/actions-wiki@<version>
  with:
    path: .
    # Notice that we use a github.com/ prefix here to support enterprise GitHub
    # deployments on other domains.
    repository: github.com/octocat/gigantic-mega-project
    # Make sure this token has the appropriate push permissions!
    token: ${{ secrets.GIGANTIC_MEGA_PROJECT_GITHUB_TOKEN }}

Options

Alternatives

There are quite a few GitHub wiki publishing actions on the GitHub Actions marketplace. There are, however, two that stick out. The newrelic/wiki-sync-action is a good choice for if you need bidirectional synchronization when someone edits the live wiki. This can be beneficial for less-technical contributors. There's also Andrew-Chen-Wang/github-wiki-action which is a direct competitor to this project. It offers more automatic features, but has more complex configuration. It also doesn't support runs-on: windows-*.

๐Ÿ“š If you're interested in more discussion of alternatives, check out #4.

Development

YAML Bash

This is a GitHub Action, so we inevitably use YAML. Make sure you quote the right things! To test ๐Ÿงช the action, the current workflow is to open a PR and then have the test.yml workflow run a dry-run: true iteration to (hopefully) spot any flaws.

To get a better handle on the contribution process, check out our handy contributing guide. Happy coding! ๐Ÿ‘‹