diff --git a/.github/workflows/wpcli-docs.yml b/.github/workflows/wpcli-docs.yml new file mode 100644 index 00000000..11902f9e --- /dev/null +++ b/.github/workflows/wpcli-docs.yml @@ -0,0 +1,78 @@ +name: WP CLI docs + +# Generate the WP CLI documentation + +on: + push: + branches: + - master + paths: + - 'includes/wp-includes/class-cli.php' + +jobs: + + wpcli-docs: + runs-on: ubuntu-latest + + permissions: + contents: write + + strategy: + matrix: + php: [ '8.0' ] + + steps: + - name: Checkout + uses: actions/checkout@v3 + + - name: install more-utils for sponge + run: sudo apt-get install moreutils + + - name: Install PHP + uses: shivammathur/setup-php@v2 + with: + php-version: ${{ matrix.php }} + coverage: xdebug + tools: composer + extensions: zip + + - name: Read .env.testing + uses: c-py/action-dotenv-to-setenv@v2 + with: + env-file: .env.testing + + - name: Run composer install + continue-on-error: true + run: composer install + + - name: Run npm install + continue-on-error: true + run: npm install + + - name: Allow writing to wp-content + run: sudo chmod -R a+w wp-content + + - name: Clear previous WP CLI documents + run: rm -rf docs/wpcli || true + + - name: Start wp-env + run: | + mkdir docs || true; + npx wp-env start --debug; + sudo chmod -R a+w wordpress/wp-content; + mkdir wordpress/wp-content/uploads || true; + sudo chmod -R a+w wordpress/wp-content/uploads; + + - name: Generate WP CLI documentation + run: composer generate-wp-cli-docs; + + - name: Add to git + run: git add -A + + - name: Commit WP CLI doc changes + uses: stefanzweifel/git-auto-commit-action@v4 + with: + commit_message: "🤖 WP CLI documentation" + + + diff --git a/composer.json b/composer.json index 5139dec9..1246d8db 100644 --- a/composer.json +++ b/composer.json @@ -104,6 +104,9 @@ }, "wp-cli/dist-archive-command": { "Add Increment Version": "https://github.com/BrianHenryIE/dist-archive-command/commit/f37c375ba8069c9160d642dd0c00435e0f1c4804.patch" + }, + "wp-cli/handbook": { + "Add wp handbook gen-custom for custom commands": "https://github.com/wp-cli/handbook/pull/526.patch" } }, "strauss": { @@ -175,6 +178,9 @@ "npx wp-env run cli /var/www/html/wp-content/plugins/example-plugin/vendor/bin/wp openapi-generator export-file example-plugin/v1 --destination=./openapi/example-plugin-openapi.json --extract-common-types;", "cat ./openapi/example-plugin-openapi.json | jq 'del(.servers) | del(.paths.\"/\") | .jsonSchemaDialect = \"https://spec.openapis.org/oas/3.1/dialect/base\"' | sponge ./openapi/example-plugin-openapi.json" ], + "generate-wp-cli-docs": [ + "npx wp-env run cli /var/www/html/wp-content/plugins/example-plugin/vendor/bin/wp handbook gen-custom example-plugin --output_dir=docs/wp-cli;" + ], "github-actions": [ "act -P ubuntu-latest=shivammathur/node:latest" ],