Skip to content

Commit 73e24a4

Browse files
committed
GH Actions: prepare the workflow for auto-generating output snippets
1 parent e557327 commit 73e24a4

File tree

1 file changed

+50
-1
lines changed

1 file changed

+50
-1
lines changed

.github/workflows/publish-wiki.yml

Lines changed: 50 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@ on:
1414
# Allow running this workflow manually from the Actions tab.
1515
workflow_dispatch:
1616
# Allow this workflow to be triggered from outside.
17+
repository_dispatch:
18+
types:
19+
- 'phpcs-release'
1720

1821
# Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued.
1922
# However, do NOT cancel in-progress runs as we want to allow these production deployments to complete.
@@ -38,6 +41,42 @@ jobs:
3841
- name: Checkout code
3942
uses: actions/checkout@v4
4043

44+
- name: Install PHP
45+
uses: shivammathur/setup-php@v2
46+
with:
47+
php-version: 'latest'
48+
ini-values: error_reporting=-1, display_errors=On, log_errors_max_len=0
49+
tools: phpcs, phpcbf
50+
coverage: none
51+
52+
# Make sure we've gotten the latest PHPCS version from setup-php.
53+
- name: Retrieve latest release info
54+
uses: octokit/[email protected]
55+
id: get_latest_release
56+
with:
57+
route: GET /repos/PHPCSStandards/PHP_CodeSniffer/releases/latest
58+
env:
59+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
60+
61+
- name: Grab latest tag name from API response
62+
id: latest_version
63+
run: |
64+
echo "TAG=${{ fromJson(steps.get_latest_release.outputs.data).tag_name }}" >> "$GITHUB_OUTPUT"
65+
66+
- name: Grab the version
67+
id: phar_version
68+
# yamllint disable-line rule:line-length
69+
run: echo "VERSION=$(phpcs --version | grep --only-matching --max-count=1 --extended-regexp '\b[0-9]+(\.[0-9]+)+')" >> "$GITHUB_OUTPUT"
70+
71+
- name: Fail the build if the PHAR is not the correct version
72+
if: ${{ steps.phar_version.outputs.VERSION != steps.latest_version.outputs.TAG }}
73+
run: exit 1
74+
75+
76+
# ################################################################################
77+
# Update Wiki files.
78+
# ################################################################################
79+
4180
- name: Install DocToc table of contents generator
4281
run: npm install -g doctoc
4382

@@ -51,6 +90,11 @@ jobs:
5190
- name: Re-run tables of contents with different settings for specific file
5291
run: doctoc ./_wiki/Version-4.0-User-Upgrade-Guide.md --github --maxlevel 3 --update-only
5392

93+
94+
# ################################################################################
95+
# Dry-run/PRs: upload artifact with pre-processed files and post comment in PR.
96+
# ################################################################################
97+
5498
# Retention is normally 90 days, but this artifact is only to help with reviewing PRs,
5599
# especially when new output blocks are added or the (workflow) code for existing ones
56100
# is updated. All in all, no need to keep the artifact for more than a few days.
@@ -74,10 +118,15 @@ jobs:
74118
A dry-run has been executed on your PR, executing all markdown pre-processing for the wiki files.
75119
76120
Please review the resulting final markdown files via the [created artifact](${{ steps.artifact.outputs.artifact-url }}).
77-
This is especially important when adding new pages.
121+
This is especially important when adding new pages or updating auto-generated output blocks.
78122
79123
_N.B.: the above link will automatically be updated when this PR is updated._
80124
125+
126+
# ################################################################################
127+
# Deploy to the wiki in the PHPCS repo.
128+
# ################################################################################
129+
81130
- name: Check GitHub Git Operations status
82131
uses: crazy-max/ghaction-github-status@v4
83132
with:

0 commit comments

Comments
 (0)