Skip to content

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

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

Conversation

jrfnl
Copy link
Member

@jrfnl jrfnl commented Jul 14, 2025

Replacement for #4, which didn't work as intended. Hopefully this one will.

What didn't work ?

  1. The github.event.head_commit.message will be empty for PR events, which would make the dry-run for the deployment fail.
  2. However, setting the commit message in a separate step ahead of the deployment runs into trouble with multi-line commit messages for push events.

So, now trying with a condition within the with for the Deploy step. 🤞🏻


This commit introduces a workflow, which will:

  • Automatically deploy the wiki files to the PHP_CodeSniffer repo 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 committers.

A prominent warning is automatically added as a (hidden) comment at the top of each wiki file to warn committers not to edit the wiki file in the GitHub wiki interface. Any edits made via the GitHub wiki interface or by directly pushing to the wiki repository, will be lost and overwritten via this workflow the next time a change is pushed to the main branch of this repo.

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:

  • The files are copied to a _wiki directory - which is .gitignored - before pre-processing to reduce the risk of the source files being accidentally updated (and committed), which would undo the automation.
  • Commits for "push" events to the main branch will get the same commit message for the wiki 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.
  • Dry-run commits for PR events and commits triggered by other events, will get a simplified message referencing the sha of the last commit.
  • 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:

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 committers.

A prominent warning is automatically added as a (hidden) comment at the top of each wiki file to warn committers not to edit the wiki file in the GitHub wiki interface.
Any edits made via the GitHub wiki interface or by directly pushing to the wiki repository, will be lost and overwritten via this workflow the next time a change is pushed to the `main` branch of this repo.

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:
* The files are copied to a `_wiki` directory - which is `.gitignore`d - before pre-processing to reduce the risk of the source files being accidentally updated (and committed), which would undo the automation.
* Commits for "push" events to the `main` branch will get the same commit message for the wiki 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.
* Dry-run commits for PR events and commits triggered by other events, will get a simplified message referencing the sha of the last commit.
* 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
@jrfnl jrfnl merged commit ad2ae7a into main Jul 14, 2025
2 checks passed
@jrfnl jrfnl deleted the feature/ghactions-add-workflow-to-deploy-to-phpcs-wiki branch July 14, 2025 20:59
@jrfnl
Copy link
Member Author

jrfnl commented Jul 14, 2025

And... it's working ;-) (at least for push and PR events)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging this pull request may close these issues.

1 participant