Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 31 additions & 11 deletions .github/workflows/update-schemas.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,34 @@ jobs:
curl -s https://develop.svn.wordpress.org/trunk/src/wp-includes/theme-i18n.json -o assets/theme-i18n.json
curl -s https://develop.svn.wordpress.org/trunk/src/wp-includes/block-i18n.json -o assets/block-i18n.json

- name: Create pull request
uses: peter-evans/create-pull-request@5f6978faf089d4d20b00c7766989d076bb2fc7f1 # v8
with:
branch: update-schemas
base: ${{ github.event.repository.default_branch }}
token: ${{ secrets.GITHUB_TOKEN }}
title: Update schema fallback files
body: "**This is an automated pull-request**\n\nRefreshes the i18n schema files with the latest changes from core.\n\nThese are only used as a fallback if they can't be accessed directly."
reviewers: swissspidy
labels: scope:distribution
commit-message: "Update schema fallback files"
- name: Commit and Create Pull Request
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
PR_BODY: |
Comment on lines +34 to +37
Copy link

Copilot AI Apr 27, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This workflow now pushes a branch and creates a PR via gh, but the workflow doesn't declare explicit permissions. If the repo/org default GITHUB_TOKEN permission is read-only, git push and gh pr create will fail. Add permissions: { contents: write, pull-requests: write } at the workflow (or job) level so this step can reliably push and open PRs.

Copilot uses AI. Check for mistakes.
**This is an automated pull-request**

Refreshes the i18n schema files with the latest changes from core.

These are only used as a fallback if they can't be accessed directly.
run: |
if [ -n "$(git status --porcelain)" ]; then
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git checkout -b update-schemas
git add assets/
git commit -m "Update schema fallback files"
git remote set-url origin https://x-access-token:${GITHUB_TOKEN}@github.com/${{ github.repository }}.git
Copy link

Copilot AI Apr 27, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

git remote set-url origin https://x-access-token:${GITHUB_TOKEN}@github.com/... unnecessarily embeds the token into the remote URL (which can get echoed in some git error output) and is redundant when actions/checkout persists credentials by default. Prefer using the checkout-provided credentials (or a safer auth mechanism like GIT_ASKPASS) instead of rewriting the remote URL with the token.

Suggested change
git remote set-url origin https://x-access-token:${GITHUB_TOKEN}@github.com/${{ github.repository }}.git

Copilot uses AI. Check for mistakes.
git push -f origin update-schemas
Copy link

Copilot AI Apr 27, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

git push -f origin update-schemas force-updates the remote branch every run, which will overwrite any manual commits or reviews added to that branch/PR. If the goal is simply to update the automation PR, consider a non-forced push (or use --force-with-lease to avoid clobbering unexpected remote updates).

Suggested change
git push -f origin update-schemas
git push --force-with-lease origin update-schemas

Copilot uses AI. Check for mistakes.

PR_NUMBER=$(gh pr list --head update-schemas --json number --jq '.[0].number')
Copy link

Copilot AI Apr 27, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PR_NUMBER=$(gh pr list ... --jq '.[0].number') will set PR_NUMBER to the literal string null when no PRs match (empty array in jq), so the subsequent -z check won't run and the PR will never be created. Adjust the jq filter (e.g., coalesce to empty) and/or explicitly treat null as empty.

Suggested change
PR_NUMBER=$(gh pr list --head update-schemas --json number --jq '.[0].number')
PR_NUMBER=$(gh pr list --head update-schemas --json number --jq '.[0].number // empty')

Copilot uses AI. Check for mistakes.
if [ -z "$PR_NUMBER" ]; then
gh pr create \
--title "Update schema fallback files" \
--body "$PR_BODY" \
--label "scope:distribution" \
--base "${{ github.event.repository.default_branch }}" \
--head "update-schemas" \
--reviewer "swissspidy"
fi
fi

Loading