Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 28 additions & 1 deletion .github/workflows/pr-backport.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -381,8 +381,35 @@ jobs:
elif [ "${reason}" = "conflicts" ]; then
# Convert comma-separated conflicts back to newlines for display
CONFLICTS_LIST=$(echo "${conflicts}" | tr ',' '\n' | sed 's/^/- /')
CONFLICTS_INLINE=$(echo "${conflicts}" | tr ',' ' ')
SAFE_TARGET=$(echo "$target" | tr '/' '-')
BACKPORT_BRANCH="backport-${PR_NUMBER}-to-${SAFE_TARGET}"
PR_URL="${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}/pull/${PR_NUMBER}"

AGENT_PROMPT="Backport PR #${PR_NUMBER} (${PR_URL}) to ${target}."$'\n'
AGENT_PROMPT+="Cherry-pick merge commit ${MERGE_COMMIT} onto new branch"$'\n'
AGENT_PROMPT+="${BACKPORT_BRANCH} from origin/${target}."$'\n'
AGENT_PROMPT+="Resolve conflicts in: ${CONFLICTS_INLINE}."$'\n'
AGENT_PROMPT+="For test snapshots (browser_tests/**/*-snapshots/), accept PR version if"$'\n'
AGENT_PROMPT+="changed in original PR, else keep target. For package.json versions, keep"$'\n'
AGENT_PROMPT+="target branch. For pnpm-lock.yaml, regenerate with pnpm install."$'\n'
AGENT_PROMPT+="Ask user for non-obvious conflicts."$'\n'
AGENT_PROMPT+="Create PR titled \"[backport ${target}] <original title>\" with label \"backport\"."$'\n'
AGENT_PROMPT+="See .github/workflows/pr-backport.yaml for workflow details."

COMMENT_BODY="### ⚠️ Backport to \`${target}\` failed"$'\n\n'
COMMENT_BODY+="**Reason:** Merge conflicts detected during cherry-pick of \`${MERGE_COMMIT:0:7}\`"$'\n\n'
COMMENT_BODY+="<details>"$'\n'"<summary>📄 Conflicting files</summary>"$'\n\n'
COMMENT_BODY+="${CONFLICTS_LIST}"$'\n\n'
COMMENT_BODY+="</details>"$'\n\n'
COMMENT_BODY+="<details>"$'\n'"<summary>🤖 Prompt for AI Agents</summary>"$'\n\n'
COMMENT_BODY+="\`\`\`"$'\n'
COMMENT_BODY+="${AGENT_PROMPT}"$'\n'
COMMENT_BODY+="\`\`\`"$'\n\n'
COMMENT_BODY+="</details>"$'\n\n'
COMMENT_BODY+="---"$'\n'
COMMENT_BODY+="cc @${PR_AUTHOR}"

COMMENT_BODY="@${PR_AUTHOR} Backport to \`${target}\` failed: Merge conflicts detected."$'\n\n'"Please manually cherry-pick commit \`${MERGE_COMMIT}\` to the \`${target}\` branch."$'\n\n'"<details><summary>Conflicting files</summary>"$'\n\n'"${CONFLICTS_LIST}"$'\n\n'"</details>"
gh pr comment "${PR_NUMBER}" --body "${COMMENT_BODY}"
fi
done
Expand Down
Loading