|
| 1 | +# This workflow keeps WordPress "Tested up to" metadata current. |
| 2 | +# It scans tracked PHP, Markdown, and text files without assuming repository-specific |
| 3 | +# metadata filenames, then opens a pull request when values need to be updated to |
| 4 | +# the latest WordPress major.minor release. |
| 5 | + |
| 6 | +name: WordPress Tested Up To |
| 7 | + |
| 8 | +on: |
| 9 | + schedule: |
| 10 | + - cron: '23 12 * * *' |
| 11 | + |
| 12 | +concurrency: |
| 13 | + group: ${{ github.workflow }}-${{ github.ref }} |
| 14 | + cancel-in-progress: true |
| 15 | + |
| 16 | +permissions: |
| 17 | + contents: write |
| 18 | + pull-requests: write |
| 19 | + |
| 20 | +env: |
| 21 | + PLUGIN_SLUG: enginescript-site-exporter |
| 22 | + |
| 23 | +jobs: |
| 24 | + tested-up-to: |
| 25 | + name: Update Tested Up To Metadata |
| 26 | + runs-on: ubuntu-latest |
| 27 | + |
| 28 | + steps: |
| 29 | + - name: Checkout code |
| 30 | + uses: actions/checkout@v6 |
| 31 | + |
| 32 | + - name: Download WordPress version data |
| 33 | + run: | |
| 34 | + curl --fail --silent --show-error --location \ |
| 35 | + --proto '=https' --tlsv1.2 \ |
| 36 | + https://api.wordpress.org/core/version-check/1.7/ \ |
| 37 | + --output wordpress-version-check.json |
| 38 | +
|
| 39 | + - name: Update WordPress Tested Up To metadata |
| 40 | + run: python3 .github/scripts/check-wordpress-tested-up-to.py --fix |
| 41 | + |
| 42 | + - name: Remove downloaded version data |
| 43 | + run: rm -f wordpress-version-check.json |
| 44 | + |
| 45 | + - name: Check for changes |
| 46 | + id: changes |
| 47 | + run: | |
| 48 | + if git diff --quiet; then |
| 49 | + echo "has_changes=false" >> "$GITHUB_OUTPUT" |
| 50 | + echo "WordPress Tested up to metadata is up to date" |
| 51 | + else |
| 52 | + echo "has_changes=true" >> "$GITHUB_OUTPUT" |
| 53 | + echo "WordPress Tested up to metadata was updated" |
| 54 | + git diff --name-only |
| 55 | + fi |
| 56 | +
|
| 57 | + - name: Create or update pull request |
| 58 | + if: steps.changes.outputs.has_changes == 'true' |
| 59 | + env: |
| 60 | + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 61 | + BRANCH_NAME: chore/update-wordpress-tested-up-to |
| 62 | + BASE_BRANCH: ${{ github.event.repository.default_branch }} |
| 63 | + PR_TITLE: 'chore: Update WordPress Tested up to metadata' |
| 64 | + run: | |
| 65 | + git config --local user.email "github-actions[bot]@users.noreply.github.com" |
| 66 | + git config --local user.name "github-actions[bot]" |
| 67 | +
|
| 68 | + git switch --create "$BRANCH_NAME" |
| 69 | + git add --update |
| 70 | + git commit -m "chore: update WordPress Tested up to metadata" |
| 71 | +
|
| 72 | + git fetch origin "$BRANCH_NAME:refs/remotes/origin/$BRANCH_NAME" 2>/dev/null || true |
| 73 | + git push --force-with-lease origin "HEAD:$BRANCH_NAME" |
| 74 | +
|
| 75 | + PR_BODY_FILE="$(mktemp)" |
| 76 | + cat > "$PR_BODY_FILE" <<'EOF' |
| 77 | + ## WordPress Tested Up To Update |
| 78 | +
|
| 79 | + This PR updates the plugin metadata to match the latest WordPress major.minor release reported by WordPress.org. |
| 80 | +
|
| 81 | + See the diff in this PR for details. |
| 82 | +
|
| 83 | + --- |
| 84 | + *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.* |
| 85 | + EOF |
| 86 | +
|
| 87 | + EXISTING_PR_URL="$( |
| 88 | + gh pr list \ |
| 89 | + --repo "$GITHUB_REPOSITORY" \ |
| 90 | + --head "$BRANCH_NAME" \ |
| 91 | + --state open \ |
| 92 | + --json url \ |
| 93 | + --jq '.[0].url // ""' |
| 94 | + )" |
| 95 | +
|
| 96 | + if [ -n "$EXISTING_PR_URL" ]; then |
| 97 | + gh pr edit "$EXISTING_PR_URL" --title "$PR_TITLE" --body-file "$PR_BODY_FILE" |
| 98 | + PR_URL="$EXISTING_PR_URL" |
| 99 | + echo "::notice::Updated pull request: $PR_URL" |
| 100 | + else |
| 101 | + PR_URL="$( |
| 102 | + gh pr create \ |
| 103 | + --repo "$GITHUB_REPOSITORY" \ |
| 104 | + --base "$BASE_BRANCH" \ |
| 105 | + --head "$BRANCH_NAME" \ |
| 106 | + --title "$PR_TITLE" \ |
| 107 | + --body-file "$PR_BODY_FILE" |
| 108 | + )" |
| 109 | + echo "::notice::Created pull request: $PR_URL" |
| 110 | + fi |
| 111 | +
|
| 112 | + gh pr edit "$PR_URL" --add-label automation --add-label maintenance || \ |
| 113 | + echo "::warning::Pull request was created, but labels could not be applied." |
0 commit comments