Fix update-framework workflow when there is an existing PR#1083
Conversation
📝 WalkthroughWalkthroughThe framework update workflow now grants read access to issues and extracts an existing open pull request number using ChangesFramework update workflow
Estimated code review effort: 1 (Trivial) | ~5 minutes 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In @.github/workflows/update-framework.yml:
- Line 76: Update the PR lookup assigned to PR_NUMBER to filter by the
repository’s default branch using the workflow event’s default-branch value, and
select only one matching open PR instead of concatenating all results. Preserve
the existing update-framework head filter so subsequent gh pr edit operations
receive a single valid PR number.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro Plus
Run ID: 8abf7c32-4e9f-447d-bc1c-7d7e1747cea9
📒 Files selected for processing (1)
.github/workflows/update-framework.yml
| git push -f origin update-framework | ||
|
|
||
| PR_NUMBER=$(gh pr list --head update-framework --json number --jq '.[0].number // empty') | ||
| PR_NUMBER=$(gh pr list --head "update-framework" --state open --template '{{range .}}{{ .number }}{{end}}') |
There was a problem hiding this comment.
🗄️ Data Integrity & Integration | 🟠 Major | ⚡ Quick win
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash
# Verify that lookup is restricted to the workflow's target base and returns one number.
set -euo pipefail
base_branch="$(gh repo view --json defaultBranchRef --jq '.defaultBranchRef.name')"
pr_number="$(gh pr list --head update-framework --base "$base_branch" --state open --json number --jq '.[0].number')"
if [[ -n "$pr_number" && ! "$pr_number" =~ ^[0-9]+$ ]]; then
echo "Invalid PR number: $pr_number" >&2
exit 1
fiRepository: wp-cli/wp-cli-bundle
Length of output: 158
🏁 Script executed:
#!/bin/bash
set -euo pipefail
file=".github/workflows/update-framework.yml"
echo "== file outline =="
sed -n '1,180p' "$file" | nl -ba | sed -n '1,180p'
echo
echo "== nearby lines around the PR lookup =="
sed -n '68,84p' "$file" | nl -baRepository: wp-cli/wp-cli-bundle
Length of output: 217
🏁 Script executed:
#!/bin/bash
set -euo pipefail
file=".github/workflows/update-framework.yml"
echo "== line count =="
wc -l "$file"
echo
echo "== relevant section =="
sed -n '1,140p' "$file" | awk '{printf "%4d %s\n", NR, $0}'
echo
echo "== gh pr usage in this workflow =="
rg -n "gh pr (list|edit)|update-framework|default_branch|base_branch|base" "$file"Repository: wp-cli/wp-cli-bundle
Length of output: 4723
Select only the PR for the workflow’s target base branch. gh pr list --head "update-framework" can match more than one open PR, and {{range .}}{{ .number }}{{end}} concatenates every number it finds. That can feed an invalid ID into gh pr edit or update the wrong PR. Add --base "${{ github.event.repository.default_branch }}" and select a single result.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In @.github/workflows/update-framework.yml at line 76, Update the PR lookup
assigned to PR_NUMBER to filter by the repository’s default branch using the
workflow event’s default-branch value, and select only one matching open PR
instead of concatenating all results. Preserve the existing update-framework
head filter so subsequent gh pr edit operations receive a single valid PR
number.
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
See https://github.com/wp-cli/wp-cli-bundle/actions/runs/29848186175/job/88694048220 which caused me to look into this.
Summary by CodeRabbit