diff --git a/.github/workflows/regenerate-handbook.yml b/.github/workflows/regenerate-handbook.yml new file mode 100644 index 00000000..d4176b53 --- /dev/null +++ b/.github/workflows/regenerate-handbook.yml @@ -0,0 +1,60 @@ +name: Regenerate Handbook + +on: + workflow_dispatch: + repository_dispatch: + types: [regenerate-handbook] + +permissions: + contents: write + +jobs: + regenerate: + name: Regenerate handbook + runs-on: ubuntu-latest + steps: + - name: Check out source code + uses: actions/checkout@v4 + + - name: Set up PHP + uses: shivammathur/setup-php@v2 + with: + php-version: 'latest' + coverage: none + + - name: Install Composer dependencies + run: composer install --no-dev + + - name: Download WP-CLI nightly + run: | + curl -O https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli-nightly.phar + chmod +x wp-cli-nightly.phar + sudo mv wp-cli-nightly.phar /usr/local/bin/wp + + - name: Verify WP-CLI installation + run: wp --info + + - name: Install non-bundled packages + run: | + chmod +x bin/install_packages.sh + bash bin/install_packages.sh + + - name: Generate handbook + run: WP_CLI_PACKAGES_DIR=bin/packages WP_CLI_CONFIG_PATH=/dev/null wp handbook gen-all + + - name: Check for changes + id: changes + run: | + git diff --exit-code --quiet HEAD || echo "has_changes=true" >> $GITHUB_OUTPUT + + - name: Commit changes + if: steps.changes.outputs.has_changes == 'true' + run: | + git config user.name "github-actions[bot]" + git config user.email "github-actions[bot]@users.noreply.github.com" + git add -A + git commit -m "Regenerate handbook" + + - name: Push changes + if: steps.changes.outputs.has_changes == 'true' + run: git push diff --git a/README.md b/README.md index 9b790aba..456ed535 100644 --- a/README.md +++ b/README.md @@ -19,6 +19,21 @@ bin/install_packages.sh WP_CLI_PACKAGES_DIR=bin/packages WP_CLI_CONFIG_PATH=/dev/null wp handbook gen-all ``` +## Automated Handbook Generation + +The handbook can be regenerated automatically using the "Regenerate Handbook" GitHub Actions workflow. This workflow can be triggered in two ways: + +1. **Manual trigger**: Navigate to the Actions tab in the GitHub repository and run the "Regenerate Handbook" workflow manually. +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`. + +The workflow will: +- Install WP-CLI nightly build +- Install non-bundled packages +- Run `wp handbook gen-all` +- Commit and push any changes to the repository + +## Documentation Import + All documentation is imported automatically into WordPress.org in a two step process: 1. WordPress reads `commands-manifest.json` or `handbook-manifest.json` to understand all pages that need to be created.