Skip to content

Commit 69c2467

Browse files
committed
GH Actions: add a workflow to automatically deploy the wiki
This commit introduces a workflow, which will: * Automatically deploy the wiki files to the [PHP_CodeSniffer repo wiki](https://github.com/PHPCSStandards/PHP_CodeSniffer/wiki) on every push to the `main` branch. * Will do a dry-run, without actually deploying whenever a PR is created which would update the wiki files. This way, the wiki is opened up to contributions via pull requests and is no longer limited to only edits made by me. This commit also adds a `_Footer.md` file, which will automatically be displayed at the bottom of each wiki page to point out that the wiki is editable via PRs to this repo. Notes: * Wiki commits will get the same commit message as the _last_ commit on the `main` branch. For that reason, merge commits are not allowed in this repo and PRs with only one commit are strongly preferred. * If the net effect of a commit results in no changes to the wiki files (CI changes and such), no commit will be made to the wiki. * The workflow is set up to fail if GitHub has an outage for git operations. That should protect the wiki from going down by a broken/partial commit and allows for retriggering a deploy once the outage has passed by re-running the failed build. Future scope (upcoming): * Automate generation of the Table of Contents for wiki pages. * Automate re-generation of output examples used in the wiki pages. Refs: * https://github.com/Andrew-Chen-Wang/github-wiki-action * https://github.com/crazy-max/ghaction-github-status
1 parent 7f08914 commit 69c2467

File tree

2 files changed

+59
-0
lines changed

2 files changed

+59
-0
lines changed

.github/workflows/publish-wiki.yml

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
name: Publish wiki
2+
on:
3+
push:
4+
branches:
5+
- 'main'
6+
paths:
7+
- wiki/**
8+
- .github/workflows/publish-wiki.yml
9+
# Do a dry-run (check, no deploy) for PRs.
10+
pull_request:
11+
paths:
12+
- wiki/**
13+
- .github/workflows/publish-wiki.yml
14+
# Allow running this workflow manually from the Actions tab.
15+
workflow_dispatch:
16+
# Allow this workflow to be triggered from outside.
17+
18+
# Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued.
19+
# However, do NOT cancel in-progress runs as we want to allow these production deployments to complete.
20+
concurrency:
21+
group: "publish-wiki"
22+
cancel-in-progress: false
23+
24+
jobs:
25+
publish-wiki:
26+
name: "Publish Wiki"
27+
if: github.repository == 'PHPCSStandards/PHP_CodeSniffer-documentation'
28+
29+
runs-on: ubuntu-latest
30+
31+
permissions:
32+
# Needed for the commit to the wiki.
33+
contents: write
34+
35+
steps:
36+
- name: Checkout code
37+
uses: actions/checkout@v4
38+
39+
- name: Check GitHub Git Operations status
40+
uses: crazy-max/ghaction-github-status@v4
41+
with:
42+
git_threshold: partial_outage
43+
44+
- name: Deploy to wiki
45+
uses: Andrew-Chen-Wang/[email protected]
46+
env:
47+
COMMIT_MSG: ${{ github.event.head_commit.message }}
48+
with:
49+
strategy: 'clone'
50+
path: 'wiki/'
51+
commit-message: ${{ env.COMMIT_MSG }}
52+
repository: PHPCSStandards/PHP_CodeSniffer
53+
token: ${{ secrets.PHPCS_PUSH_TO_WIKI_TOKEN }}
54+
dry-run: ${{ github.event_name == 'pull_request' }}
55+
disable-empty-commits: true
56+
preprocess: false

wiki/_Footer.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
_Found a mistake ? Think this documentation can be improved ?_
2+
3+
Contributions to this wiki are welcome! Submit a pull request to the [Documentation repository](https://github.com/PHPCSStandards/PHP_CodeSniffer-documentation) to propose your changes.

0 commit comments

Comments
 (0)