-
Notifications
You must be signed in to change notification settings - Fork 4.2k
69 lines (59 loc) · 2.32 KB
/
doc-pr-cherry-pick.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
name: Cherry-Pick PR to v2
on:
workflow_dispatch:
inputs:
pr_number:
description: 'PR number to cherry-pick'
type: string
required: true
jobs:
cherry_pick_and_create_pr:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # 4.2.2
with:
fetch-depth: 0
- name: Configure Git
run: |
git config user.name "aws-sdk-python-automation"
git config user.email "[email protected]"
- name: Get PR commits
id: get_commits
run: |
gh pr checkout $PR_NUMBER
PR_COMMITS=$(gh pr view $PR_NUMBER --json commits --jq '.commits[].oid')
echo "PR_COMMITS=$PR_COMMITS" >> $GITHUB_OUTPUT
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
PR_NUMBER: ${{ github.event.inputs.pr_number }}
- name: Create new branch and cherry-pick commits
id: create_branch
run: |
git fetch origin v2
NEW_BRANCH="v2-sync-pr-$PR_NUMBER"
git checkout -b $NEW_BRANCH origin/v2
for commit in $PR_COMMITS; do
git cherry-pick $commit
done
git push origin $NEW_BRANCH
echo "NEW_BRANCH=$NEW_BRANCH" >> $GITHUB_OUTPUT
env:
PR_NUMBER: ${{ github.event.inputs.pr_number }}
PR_COMMITS: ${{ steps.get_commits.outputs.PR_COMMITS}}
- name: Create new PR
run: |
PR_TITLE=$(gh pr view $PR_NUMBER --json title --jq '.title')
PR_BODY=$(cat << EOF
This PR cherry-picks the commits from #$PR_NUMBER to the v2 branch.
Please complete the following checklist before merging:
- [ ] Verify that the original PR (#$PR_NUMBER) is approved
- [ ] Verify that this merge to v2 is appropriate
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.
EOF
)
gh pr create --title "[V2] $PR_TITLE" --body "$PR_BODY" --base v2 --head $NEW_BRANCH
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
PR_NUMBER: ${{ github.event.inputs.pr_number }}
NEW_BRANCH: ${{ steps.create_branch.outputs.NEW_BRANCH}}