Skip to content

Commit 2c45e97

Browse files
pawel-kowbankole175
authored andcommitted
Fix: don't swap review labels on "Update branch" (Domain-Connect#1227)
## Fix: don't swap review labels on "Update branch" ### Problem Clicking "Update branch" on a PR creates a merge commit from `master` into the PR branch. This triggered the `synchronize` event, causing the workflow to incorrectly swap `review issues` → `new review needed` even though the PR author had not pushed any new work. Example: commit `27072ddd` on PR Domain-Connect#1218. ### Fix In the trigger workflow, before treating a `synchronize` event as new author work, check whether the head commit is a two-parent merge commit whose second parent matches the current `master` tip. If it is, skip the artifact upload entirely — no label changes are made. All other pushes (regular commits, force-pushes, author-initiated merges) continue to trigger the label swap as before.
1 parent 1e6be16 commit 2c45e97

1 file changed

Lines changed: 18 additions & 0 deletions

File tree

.github/workflows/review-trigger.yml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,24 @@ jobs:
3030
action="changes_requested"
3131
fi
3232
elif [ "${{ github.event_name }}" = "pull_request_target" ]; then
33+
# Skip "Update branch" merge commits (base branch merged into PR).
34+
# These have two parents where the second parent is the base branch
35+
# tip -- they represent no new author work, so labels should not swap.
36+
head_sha="${{ github.event.pull_request.head.sha }}"
37+
repo="${{ github.repository }}"
38+
parent_count=$(gh api "repos/$repo/commits/$head_sha" \
39+
--jq '.parents | length')
40+
if [ "$parent_count" -ge 2 ]; then
41+
second_parent=$(gh api "repos/$repo/commits/$head_sha" \
42+
--jq '.parents[1].sha')
43+
base_sha=$(gh api "repos/$repo/git/refs/heads/master" \
44+
--jq '.object.sha')
45+
if [ "$second_parent" = "$base_sha" ]; then
46+
echo "Head commit is an \"Update branch\" merge; skipping."
47+
echo "skip=true" >> "$GITHUB_OUTPUT"
48+
exit 0
49+
fi
50+
fi
3351
pr_number="${{ github.event.pull_request.number }}"
3452
action="new_commits"
3553
fi

0 commit comments

Comments
 (0)