From 4a5be952e54e28ed8eee47929ff198ddf8945905 Mon Sep 17 00:00:00 2001 From: selmankoc Date: Thu, 10 Sep 2026 13:56:17 +0300 Subject: [PATCH] Add notification for human authors on merge conflicts in auto-merge workflow --- .github/workflows/auto-merge-forward.yml | 55 ++++++++++++++++++++++++ 1 file changed, 55 insertions(+) diff --git a/.github/workflows/auto-merge-forward.yml b/.github/workflows/auto-merge-forward.yml index 187bf488fb..7782313236 100644 --- a/.github/workflows/auto-merge-forward.yml +++ b/.github/workflows/auto-merge-forward.yml @@ -131,6 +131,61 @@ jobs: echo "url=$URL" >> "$GITHUB_OUTPUT" echo "Created $URL" + # Conflict PRs stay open; assign/request review from human commit authors so they get + # GitHub notifications. Cascade pushes are often from a bot, so do not use github.actor. + - name: Notify humans on conflict + if: steps.target.outputs.skip != 'true' && steps.merge.outputs.conflict == 'true' + env: + GH_TOKEN: ${{ github.token }} + run: | + set -euo pipefail + SOURCE="${{ steps.target.outputs.source }}" + TARGET="${{ steps.target.outputs.target }}" + FORWARD_BRANCH="${{ steps.merge.outputs.branch }}" + REPO="${{ github.repository }}" + + # Compare returns at most 250 commits; enough for a typical forward hop. + mapfile -t USERS < <( + gh api "repos/${REPO}/compare/${TARGET}...${SOURCE}" \ + --jq ' + [.commits[]?.author.login // empty] + | unique + | .[] + | select( + . != "" + and (endswith("[bot]") | not) + and . != "github-actions" + ) + ' + ) + + if ((${#USERS[@]} == 0)); then + echo "::warning::Merge conflict on ${SOURCE} → ${TARGET}, but no human GitHub authors were found on the forwarded commits." + exit 0 + fi + + MENTIONS=() + for user in "${USERS[@]}"; do + MENTIONS+=("@${user}") + if gh pr edit "$FORWARD_BRANCH" --add-assignee "$user"; then + echo "Assigned $user" + else + echo "::warning::Could not assign $user (may lack repo access)." + fi + if gh pr edit "$FORWARD_BRANCH" --add-reviewer "$user"; then + echo "Requested review from $user" + else + echo "::warning::Could not request review from $user." + fi + done + + COMMENT="$(printf '%s\n' \ + "**Merge conflict** forwarding \`${SOURCE}\` → \`${TARGET}\`." \ + "" \ + "Please resolve conflicts against \`${TARGET}\` and merge manually." \ + "cc ${MENTIONS[*]}")" + gh pr comment "$FORWARD_BRANCH" --body "$COMMENT" + # BOT_SECRET, not github.token: a merge performed with the default token produces a push # that triggers no workflow, which would stop the chain at the first hop. - name: Approve and auto-merge