Skip to content

Commit ba78a5a

Browse files
authored
Gt 367 grabbing pr num and url correctly (#296)
* ci: updating sync workflow to pull pr num and url correctly * chore: adding label to skip changeset check * chore: fixing merge conflict
1 parent 4d593b2 commit ba78a5a

File tree

1 file changed

+16
-9
lines changed

1 file changed

+16
-9
lines changed

.github/workflows/sync-develop.yml

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -115,11 +115,14 @@ jobs:
115115
--title "${{ steps.meta.outputs.sync_title }}" \
116116
--body "${{ steps.meta.outputs.sync_body }} (created via gh CLI)" \
117117
--label back-merge \
118+
--label skip-changeset \
118119
--label automation
119120
120-
# Emit outputs for later steps
121-
gh pr view --base "${BASE_BRANCH}" --head "${{ steps.meta.outputs.sync_branch }}" \
122-
--json number,url | jq -r '"pr_number=\(.number)\npr_url=\(.url)"' >> "$GITHUB_OUTPUT"
121+
# Fetch the newly created PR number, then its URL so that we display in a PR comment
122+
num=$(gh pr list --base "${BASE_BRANCH}" --head "${{ steps.meta.outputs.sync_branch }}" --state open --json number --jq '.[0].number')
123+
url=$(gh pr view "$num" --json url --jq .url)
124+
echo "pr_number=$num" >> "$GITHUB_OUTPUT"
125+
echo "pr_url=$url" >> "$GITHUB_OUTPUT"
123126
124127
# If the merge hit conflicts, open a DIRECT PR: HEAD_BRANCH -> BASE_BRANCH so conflicts can be resolved prior to merge
125128
- name: Open conflict PR
@@ -155,10 +158,14 @@ jobs:
155158
--body "${{ steps.meta.outputs.conflict_body }}" \
156159
--label back-merge \
157160
--label automation \
161+
--label skip-changeset \
158162
--label conflicts
159163
160-
gh pr view --base "${BASE_BRANCH}" --head "${{ steps.meta.outputs.conflict_branch }}" \
161-
--json number,url | jq -r '"pr_number=\(.number)\npr_url=\(.url)"' >> "$GITHUB_OUTPUT"
164+
# Fetch the newly created conflict PR number, then its URL so that we display in a PR comment
165+
num=$(gh pr list --base "${BASE_BRANCH}" --head "${{ steps.meta.outputs.conflict_branch }}" --state open --json number --jq '.[0].number')
166+
url=$(gh pr view "$num" --json url --jq .url)
167+
echo "pr_number=$num" >> "$GITHUB_OUTPUT"
168+
echo "pr_url=$url" >> "$GITHUB_OUTPUT"
162169
163170
# Comment back on the ORIGINAL merged PR with a link to the sync PR
164171
- name: Comment on source PR with sync PR link
@@ -169,22 +176,22 @@ jobs:
169176
const owner = context.repo.owner;
170177
const repo = context.repo.repo;
171178
const issue_number = Number(process.env.SOURCE_PR);
172-
179+
173180
const hadConflicts = '${{ steps.prep.outputs.merge_status }}' !== '0';
174181
const syncUrl = '${{ steps.sync_pr.outputs.pr_url || steps.conflict_pr.outputs.pr_url }}';
175182
const head = process.env.HEAD_BRANCH;
176183
const base = process.env.BASE_BRANCH;
177-
184+
178185
const status = hadConflicts ? 'conflicts ❗' : 'clean ✅';
179186
const note = hadConflicts
180187
? 'Opened from a copy of main so conflicts can be resolved safely.'
181188
: 'Opened from a sync branch created off develop.';
182-
189+
183190
const body = [
184191
`Opened sync PR **${head} → ${base}**: ${syncUrl}`,
185192
``,
186193
`Merge status: **${status}**`,
187194
note
188195
].join('\n');
189-
196+
190197
await github.rest.issues.createComment({ owner, repo, issue_number, body });

0 commit comments

Comments
 (0)