-
Notifications
You must be signed in to change notification settings - Fork 60
Use gh pr create for update-schemas workflow
#491
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -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: | | ||||||
| **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 | ||||||
|
||||||
| git remote set-url origin https://x-access-token:${GITHUB_TOKEN}@github.com/${{ github.repository }}.git |
Copilot
AI
Apr 27, 2026
There was a problem hiding this comment.
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).
| git push -f origin update-schemas | |
| git push --force-with-lease origin update-schemas |
Copilot
AI
Apr 27, 2026
There was a problem hiding this comment.
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.
| 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') |
There was a problem hiding this comment.
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 explicitpermissions. If the repo/org default GITHUB_TOKEN permission is read-only,git pushandgh pr createwill fail. Addpermissions: { contents: write, pull-requests: write }at the workflow (or job) level so this step can reliably push and open PRs.