Skip to content

Commit e180a42

Browse files
authored
Merge pull request #590 from wp-cli/copilot/add-github-actions-for-handbook
2 parents 1c1001f + 5ad1f8e commit e180a42

File tree

2 files changed

+75
-0
lines changed

2 files changed

+75
-0
lines changed
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
name: Regenerate Handbook
2+
3+
on:
4+
workflow_dispatch:
5+
repository_dispatch:
6+
types: [regenerate-handbook]
7+
8+
permissions:
9+
contents: write
10+
11+
jobs:
12+
regenerate:
13+
name: Regenerate handbook
14+
runs-on: ubuntu-latest
15+
steps:
16+
- name: Check out source code
17+
uses: actions/checkout@v4
18+
19+
- name: Set up PHP
20+
uses: shivammathur/setup-php@v2
21+
with:
22+
php-version: 'latest'
23+
coverage: none
24+
25+
- name: Install Composer dependencies
26+
run: composer install --no-dev
27+
28+
- name: Download WP-CLI nightly
29+
run: |
30+
curl -O https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli-nightly.phar
31+
chmod +x wp-cli-nightly.phar
32+
sudo mv wp-cli-nightly.phar /usr/local/bin/wp
33+
34+
- name: Verify WP-CLI installation
35+
run: wp --info
36+
37+
- name: Install non-bundled packages
38+
run: |
39+
chmod +x bin/install_packages.sh
40+
bash bin/install_packages.sh
41+
42+
- name: Generate handbook
43+
run: WP_CLI_PACKAGES_DIR=bin/packages WP_CLI_CONFIG_PATH=/dev/null wp handbook gen-all
44+
45+
- name: Check for changes
46+
id: changes
47+
run: |
48+
git diff --exit-code --quiet HEAD || echo "has_changes=true" >> $GITHUB_OUTPUT
49+
50+
- name: Commit changes
51+
if: steps.changes.outputs.has_changes == 'true'
52+
run: |
53+
git config user.name "github-actions[bot]"
54+
git config user.email "github-actions[bot]@users.noreply.github.com"
55+
git add -A
56+
git commit -m "Regenerate handbook"
57+
58+
- name: Push changes
59+
if: steps.changes.outputs.has_changes == 'true'
60+
run: git push

README.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,21 @@ bin/install_packages.sh
1919
WP_CLI_PACKAGES_DIR=bin/packages WP_CLI_CONFIG_PATH=/dev/null wp handbook gen-all
2020
```
2121

22+
## Automated Handbook Generation
23+
24+
The handbook can be regenerated automatically using the "Regenerate Handbook" GitHub Actions workflow. This workflow can be triggered in two ways:
25+
26+
1. **Manual trigger**: Navigate to the Actions tab in the GitHub repository and run the "Regenerate Handbook" workflow manually.
27+
2. **Automated trigger from wp-cli/wp-cli**: When a new version of WP-CLI is released, the main framework repository can trigger this workflow using a `repository_dispatch` event with type `regenerate-handbook`.
28+
29+
The workflow will:
30+
- Install WP-CLI nightly build
31+
- Install non-bundled packages
32+
- Run `wp handbook gen-all`
33+
- Commit and push any changes to the repository
34+
35+
## Documentation Import
36+
2237
All documentation is imported automatically into WordPress.org in a two step process:
2338

2439
1. WordPress reads `commands-manifest.json` or `handbook-manifest.json` to understand all pages that need to be created.

0 commit comments

Comments
 (0)