Skip to content

GH Actions: add a workflow to automatically deploy the wiki #4

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 14, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
82 changes: 82 additions & 0 deletions .github/workflows/publish-wiki.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
name: Publish wiki
on:
push:
branches:
- 'main'
paths:
- wiki/**
- .github/workflows/publish-wiki.yml
# Do a dry-run (check, no deploy) for PRs.
pull_request:
paths:
- wiki/**
- .github/workflows/publish-wiki.yml
# Allow running this workflow manually from the Actions tab.
workflow_dispatch:
# Allow this workflow to be triggered from outside.

# Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued.
# However, do NOT cancel in-progress runs as we want to allow these production deployments to complete.
concurrency:
group: "publish-wiki"
cancel-in-progress: false

jobs:
publish-wiki:
name: "Publish Wiki"
if: github.repository == 'PHPCSStandards/PHP_CodeSniffer-documentation'

runs-on: ubuntu-latest

permissions:
# Needed for the commit to the wiki.
contents: write

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Copy wiki files to temporary location
shell: bash
run: cp -v -a wiki _wiki

- name: Preface markdown files with warning not to edit in place
shell: bash
# yamllint disable rule:line-length
# shellcheck disable=SC2016
run: >
find ./_wiki/ -name "*.md*"
-exec sed -i
'1i\<!--\nWARNING: DO NOT EDIT THIS FILE IN THE WIKI.\nThis wiki is updated from the https://github.com/PHPCSStandards/PHP_CodeSniffer-documentation repository.\nSubmit a PR to that repository updating the relevant file in the /wiki/ subdirectory instead.\n-->\n' {} \;
# yamllint enable rule:line-length

- name: Prepare commit message
id: commit_msg
env:
COMMIT_MSG: ${{ github.event.head_commit.message }}
PR_TITLE: ${{ github.event.pull_request.title }}
run: |
if [[ "${{ github.event_name }}" == 'pull_request' ]]; then
echo "MSG=Wiki dry-run for PR $PR_TITLE" >> "$GITHUB_OUTPUT"
elif [[ "$COMMIT_MSG" != '' ]]; then
echo "MSG=$COMMIT_MSG" >> "$GITHUB_OUTPUT"
else
echo "MSG=Update wiki ${{ github.sha }}" >> "$GITHUB_OUTPUT"
fi

- name: Check GitHub Git Operations status
uses: crazy-max/ghaction-github-status@v4
with:
git_threshold: partial_outage

- name: Deploy to wiki
uses: Andrew-Chen-Wang/[email protected]
with:
strategy: 'clone'
path: '_wiki/'
commit-message: ${{ steps.commit_msg.outputs.MSG }}
repository: PHPCSStandards/PHP_CodeSniffer
token: ${{ secrets.PHPCS_PUSH_TO_WIKI_TOKEN }}
dry-run: ${{ github.event_name == 'pull_request' }}
disable-empty-commits: true
preprocess: false
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
_wiki/
3 changes: 3 additions & 0 deletions wiki/_Footer.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
_Found a mistake ? Think this documentation can be improved ?_

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.