10up Actions for WordPress
repository·stable·Indexed 19 days ago
https://github.com/10up/actions-wordpressA collection of GitHub Actions and workflows for WordPress development. Features include deployment to WordPress.org and Pantheon, PHP linting via wpcs-action, security scanning with wp-scanner-action, and repository automation using action-repo-automator. Also includes tools for building plugin zip archives, updating WordPress.org assets, and generating hook documentation via WP Hooks Documentor.
What's inside 10up-actions-wordpress
- This repository provides a collection of GitHub Actions and workflows designed to automate common tasks in WordPress development. These tools cover plugin deployment, build processes, linting, site deployment, security scanning, and repository automation. Each individual Action has its own dedicated repository for detailed documentation and specific configuration instructions.
Document WordPress hooks using PHPDoc
stableWP Hooks Documentor relies on standard WordPress PHPDoc comments to extract hook information. It detects
apply_filters()for filters anddo_action()for actions.To ensure hooks are correctly documented, include:
- A description of the hook.
@sinceversion tag.@paramtags with types and descriptions for all arguments.@returntag for filter hooks.
Filter Example
/** * Filters the taxonomies that should be synced. * * @since 1.0.0 * * @param array $taxonomies Associative array list of taxonomies supported by current post in the format of `$taxonomy => $terms`. * @param WP_Post $post The post object. * * @return array Associative array list of taxonomies supported by current post in the format of `$taxonomy => $terms`. */ $taxonomies = apply_filters( 'dt_syncable_taxonomies', $taxonomies, $post );Action Example
/** * Fires the action after a post is pushed via Distributor before remote request validation. * * @since 2.0.0 * * @param array|WP_Error $response The response from the remote request. * @param array $post_body The Post data formatted for the REST API endpoint. * @param string $type_url The Post type api endpoint. * @param int $post_id The Post id. * @param array $args The arguments passed into wp_insert_post. * @param WordPressExternalConnection $this The Distributor connection being pushed to. */ do_action( 'dt_push_external_post', $response, $post_body, $type_url, $post_id, $args, $this );Deploy plugin asset or readme updates to WordPress.org
stableTheaction-wordpress-plugin-asset-updateAction allows you to update WordPress.org assets (like screenshots) or thereadme.txtfile without a full plugin release. If a push to your specified branch contains only changes to the WordPress.org assets directory (defaults to/.wordpress-org) orreadme.txt, these changes are deployed directly to the WordPress.org plugin repository.Migrate to the new WordPress.org Plugin Deploy repository
stableThe
WordPress.org Plugin Deployaction has moved to a new repository. While existing workflows using this action will continue to function without immediate changes, it is recommended to migrate to the new repository to ensure you receive future updates and improvements.New repository:
https://github.com/10up/action-wordpress-plugin-deployDeploy Hook Documentation to GitHub Pages via GitHub Actions
stableYou can automate the generation and deployment of your hook documentation using a GitHub Actions workflow.
Workflow Requirements
- A workflow file in
.github/workflows/. - The workflow must install dependencies, run the documentation generation command, and use an action like
peaceiris/actions-gh-pagesto deploy thepublish_dirto thegh-pagesbranch.
Example Workflow (
.github/workflows/build-docs.yml)name: Build Hook Documentation on: push: branches: - trunk jobs: build-docs: runs-on: ubuntu-latest steps: - name: Checkout uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 - name: Setup proper PHP version uses: shivammathur/setup-php@9e72090525849c5e82e596468b86eb55e9cc5401 # v2.32.0 with: php-version: 8.3 - name: Setup node uses: actions/setup-node@cdca7365b2dadb8aad0a33bc7601856ffabcc48e # v4.3.0 with: node-version: 20 - name: npm install, and build docs run: | npm install npm run build:docs - name: Deploy to GH Pages uses: peaceiris/actions-gh-pages@4f9cc6602d3f66b9c108549d475ec49e8ef4d45e # v4.0.0 with: github_token: ${{ secrets.GITHUB_TOKEN }} publish_dir: './docs/build'- A workflow file in
Validate project dependency licensing
stableTo ensure your project adheres to specific licensing requirements (e.g., GPLv2 compatibility), you can use a specialized GitHub Action workflow and a GPL-Compatible License Policy file. This validates that all project dependencies use compatible licenses.Scan WordPress sites for vulnerabilities
stableThe
wp-scanner-actionperforms syntax checks, virus scans, and known vulnerability checks for WordPress sites. It uses the WP-CLI Vulnerability Scanner, which integrates with:- WPScan
- Patchstack
- Wordfence Intelligence (Authentication is optional for this API).
This Action helps ensure your plugins and themes are secure against reported vulnerabilities.
Lint PHP code with WordPress Coding Standards
stableThewpcs-actionperforms PHP linting usingPHP_CodeSniffer(PHPCS) against the WordPress Coding Standards. It provides warnings and errors as annotations directly in your Pull Requests without requiring you to add PHPCS or a configuration file as a dependency in your codebase.Generate PHPCS markdown summaries in GitHub Actions
stableYou can convert PHP CodeSniffer (PHPCS) JSON reports into Markdown summaries for the GitHub Actions job summary. This uses the
phpcs-json-to-mdtool.Steps to implement:
- Configure your PHPCS check (e.g., using
10up/wpcs-action) to output a JSON report using the--report-jsonargument. - Use
npx github:10up/phpcs-json-to-mdto convert the JSON report to a Markdown file. - Append the Markdown file to
$GITHUB_STEP_SUMMARY. - Use the conditional
if: ${{ failure() }}to ensure the summary is only updated when the PHPCS check fails.
jobs: phpcs: name: WPCS runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 - name: WPCS check uses: 10up/wpcs-action@stable with: use_local_config: true extra_args: '--report-json=./phpcs-report.json' - name: Update summary run: | npx github:10up/phpcs-json-to-md --path ./phpcs-report.json --output ./phpcs-report.md cat phpcs-report.md >> $GITHUB_STEP_SUMMARY if: ${{ failure() }}- Configure your PHPCS check (e.g., using
Test WP Hooks documentation locally
stableTo preview your documentation before deploying, generate the files and use a local server:
- Generate the documentation:
npm run docs:generate- Navigate to the output directory (default is
./docs):
cd ./docs- Start the local development server:
npm run serveThe site will be available at
http://localhost:3000.npm run docs:generate cd ./docs npm run serveAutomate repository operations with action-repo-automator
stableThe
action-repo-automatorautomates various GitHub repository management tasks, including:- PR Validation: Validates that descriptions contain required sections (description, changelog, credits) and allows custom error messages.
- Labeling: Automatically adds labels when PR validation passes/fails or when merge conflicts are detected (and removes them once resolved).
- Issue/PR Management: Auto-assigns issues to PR assignees, auto-assigns PRs to authors, and adds milestones to PRs based on connected issues.
- Review Management: Automatically requests reviews from specific teams or users.
- Branch Syncing: Automatically keeps PR branches up to date with the base branch.
- Contributor Engagement: Welcomes first-time contributors and adds automated comments to new issues or PRs.
Generate ESLint markdown summaries in GitHub Actions
stableTo improve developer experience, you can convert ESLint JSON reports into readable Markdown summaries in the GitHub Actions job summary. This is achieved by using the
eslint-json-to-mdtool to convert the JSON report to Markdown, and then appending that Markdown content to the$GITHUB_STEP_SUMMARYenvironment variable.Key implementation details:
- Use the
--output-fileflag with your linting command to generate a JSON report. - Use
npx github:10up/eslint-json-to-mdto perform the conversion. - Append the resulting file to
$GITHUB_STEP_SUMMARYusingcat. - It is recommended to run the summary update step only
if: ${{ failure() }}so that reports are only generated when linting issues are actually found.
jobs: eslint: name: eslint runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 - name: npm install run: npm install - name: Generate linting report run: npm run lint:js -- --output-file eslint-report.json --format json continue-on-error: true - name: Annotate code linting results uses: ataylorme/eslint-annotate-action@1.2.0 with: repo-token: '${{ secrets.GITHUB_TOKEN }}' report-json: 'eslint-report.json' - name: Update summary run: | npm_config_yes=true npx github:10up/eslint-json-to-md --path ./eslint-report.json --output ./eslint-report.md cat eslint-report.md >> $GITHUB_STEP_SUMMARY if: ${{ failure() }}- Use the