File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11name : Backport fixes to stable branch
22
33on :
4- pull_request_target :
5- types : [closed]
4+ push :
5+ branches :
6+ - master
67 issue_comment :
78 types : [created]
89
@@ -11,18 +12,20 @@ permissions:
1112 pull-requests : write
1213
1314jobs :
14- backport :
15+ backport-on-push :
16+ if : github.event_name == 'push'
17+ uses : ./.github/workflows/reusable-backport.yml
18+ with :
19+ commit_sha : ${{ github.sha }}
20+
21+ backport-on-comment :
1522 if : >
16- (
17- github.event_name == 'pull_request_target' &&
18- github.event.pull_request.merged
19- ) || (
20- github.event_name == 'issue_comment' &&
21- github.event.issue.pull_request &&
22- github.event.issue.state == 'closed' &&
23- contains(fromJSON('["MEMBER", "OWNER"]'), github.event.comment.author_association) &&
24- github.event.comment.body == '/backport'
25- )
23+ github.event_name == 'issue_comment' &&
24+ github.event.issue.pull_request &&
25+ github.event.issue.state == 'closed' &&
26+ contains(fromJSON('["MEMBER", "OWNER"]'), github.event.comment.author_association) &&
27+ startsWith(github.event.comment.body, '/backport')
2628 uses : ./.github/workflows/reusable-backport.yml
2729 with :
28- source_pr_number : ${{ github.event.pull_request.number || github.event.issue.number }}
30+ pr_number : ${{ github.event.issue.number }}
31+ comment_body : ${{ github.event.comment.body }}
Original file line number Diff line number Diff line change @@ -88,18 +88,20 @@ jobs:
8888 --title "[backport] $PR_TITLE (to $BRANCH)" \
8989 --body "Backport of #$PR_NUMBER to \`$BRANCH\`."
9090 else
91- git cherry-pick --abort
92- gh pr comment "$PR_NUMBER" \
93- --body "❌ Cherry-pick to \`$BRANCH\` failed due to conflicts. Please backport manually:
94-
95- \`\`\`bash
96- git fetch origin $BRANCH
97- git checkout -b backport/${PR_NUMBER}-to-${BRANCH} origin/$BRANCH
98- git cherry-pick -x $SHA
99- # resolve conflicts
100- git cherry-pick --continue
101- git push origin backport/${PR_NUMBER}-to-${BRANCH}
102- \`\`\`
103-
104- Then open a PR targeting \`$BRANCH\`."
91+ git cherry-pick --abort || true
92+ {
93+ echo "❌ Cherry-pick to \`$BRANCH\` failed due to conflicts. Please backport manually:"
94+ echo ""
95+ echo "\`\`\`bash"
96+ echo "git fetch origin $BRANCH master"
97+ echo "git checkout -b backport/${PR_NUMBER}-to-${BRANCH} origin/$BRANCH"
98+ echo "git cherry-pick -x $SHA"
99+ echo "# resolve conflicts"
100+ echo "git cherry-pick --continue"
101+ echo "git push origin backport/${PR_NUMBER}-to-${BRANCH}"
102+ echo "\`\`\`"
103+ echo ""
104+ echo "Then open a PR targeting \`$BRANCH\`."
105+ } > /tmp/backport-comment.md
106+ gh pr comment "$PR_NUMBER" --body-file /tmp/backport-comment.md
105107 fi
You can’t perform that action at this time.
0 commit comments