WordPress Tested Up To #1
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # This workflow keeps WordPress "Tested up to" metadata current. | |
| # It scans tracked PHP, Markdown, and text files without assuming repository-specific | |
| # metadata filenames, then opens a pull request when values need to be updated to | |
| # the latest WordPress major.minor release. | |
| name: WordPress Tested Up To | |
| on: | |
| schedule: | |
| - cron: '23 12 * * *' | |
| concurrency: | |
| group: ${{ github.workflow }}-${{ github.ref }} | |
| cancel-in-progress: true | |
| permissions: | |
| contents: write | |
| pull-requests: write | |
| env: | |
| PLUGIN_SLUG: enginescript-site-exporter | |
| jobs: | |
| tested-up-to: | |
| name: Update Tested Up To Metadata | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v6 | |
| - name: Download WordPress version data | |
| run: | | |
| curl --fail --silent --show-error --location \ | |
| --proto '=https' --tlsv1.2 \ | |
| https://api.wordpress.org/core/version-check/1.7/ \ | |
| --output wordpress-version-check.json | |
| - name: Update WordPress Tested Up To metadata | |
| run: python3 .github/scripts/check-wordpress-tested-up-to.py --fix | |
| - name: Remove downloaded version data | |
| run: rm -f wordpress-version-check.json | |
| - name: Check for changes | |
| id: changes | |
| run: | | |
| if git diff --quiet; then | |
| echo "has_changes=false" >> "$GITHUB_OUTPUT" | |
| echo "WordPress Tested up to metadata is up to date" | |
| else | |
| echo "has_changes=true" >> "$GITHUB_OUTPUT" | |
| echo "WordPress Tested up to metadata was updated" | |
| git diff --name-only | |
| fi | |
| - name: Create or update pull request | |
| if: steps.changes.outputs.has_changes == 'true' | |
| env: | |
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| BRANCH_NAME: chore/update-wordpress-tested-up-to | |
| BASE_BRANCH: ${{ github.event.repository.default_branch }} | |
| PR_TITLE: 'chore: Update WordPress Tested up to metadata' | |
| run: | | |
| git config --local user.email "github-actions[bot]@users.noreply.github.com" | |
| git config --local user.name "github-actions[bot]" | |
| git switch --create "$BRANCH_NAME" | |
| git add --update | |
| git commit -m "chore: update WordPress Tested up to metadata" | |
| git fetch origin "$BRANCH_NAME:refs/remotes/origin/$BRANCH_NAME" 2>/dev/null || true | |
| git push --force-with-lease origin "HEAD:$BRANCH_NAME" | |
| PR_BODY_FILE="$(mktemp)" | |
| cat > "$PR_BODY_FILE" <<'EOF' | |
| ## WordPress Tested Up To Update | |
| This PR updates the plugin metadata to match the latest WordPress major.minor release reported by WordPress.org. | |
| See the diff in this PR for details. | |
| --- | |
| *This PR was automatically generated by the [WordPress Tested Up To](https://github.com/${{ github.repository }}/blob/main/.github/workflows/wordpress-tested-up-to.yml) workflow.* | |
| EOF | |
| EXISTING_PR_URL="$( | |
| gh pr list \ | |
| --repo "$GITHUB_REPOSITORY" \ | |
| --head "$BRANCH_NAME" \ | |
| --state open \ | |
| --json url \ | |
| --jq '.[0].url // ""' | |
| )" | |
| if [ -n "$EXISTING_PR_URL" ]; then | |
| gh pr edit "$EXISTING_PR_URL" --title "$PR_TITLE" --body-file "$PR_BODY_FILE" | |
| PR_URL="$EXISTING_PR_URL" | |
| echo "::notice::Updated pull request: $PR_URL" | |
| else | |
| PR_URL="$( | |
| gh pr create \ | |
| --repo "$GITHUB_REPOSITORY" \ | |
| --base "$BASE_BRANCH" \ | |
| --head "$BRANCH_NAME" \ | |
| --title "$PR_TITLE" \ | |
| --body-file "$PR_BODY_FILE" | |
| )" | |
| echo "::notice::Created pull request: $PR_URL" | |
| fi | |
| gh pr edit "$PR_URL" --add-label automation --add-label maintenance || \ | |
| echo "::warning::Pull request was created, but labels could not be applied." |