Skip to content

Commit 32f68b0

Browse files
authored
cherry pick to chosen branch (#7678)
1 parent 790e270 commit 32f68b0

File tree

1 file changed

+28
-10
lines changed

1 file changed

+28
-10
lines changed

.github/workflows/cherry-pick.yml

+28-10
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
name: "Cherry-pick dependencies to release branch"
22
on:
3-
pull_request:
4-
branches:
5-
- main
6-
types: ["closed"]
3+
issue_comment:
4+
types:
5+
- created
76

87
permissions:
98
contents: read
@@ -15,23 +14,42 @@ jobs:
1514
pull-requests: write
1615
runs-on: ubuntu-22.04
1716
name: Cherry pick into release branch
18-
if: ${{ (contains(github.event.pull_request.labels.*.name, 'dependencies') || contains(github.event.pull_request.labels.*.name, 'needs cherry pick')) && github.event.pull_request.merged == true }}
17+
if: ${{ github.event.issue.pull_request.merged_at != null }}
1918
steps:
2019
- name: Checkout
2120
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
2221
with:
2322
fetch-depth: 0
24-
token: ${{ secrets.NGINX_PAT }}
23+
24+
- name: Check if Actor is a Member of one of the teams
25+
uses: im-open/is-actor-team-member@6633b6e4d9bd2a6917f976b14c64626902e13805 # v1.2.0
26+
with:
27+
github-actor: ${{ github.actor }}
28+
github-organization: ${{ github.repository_owner}}
29+
github-team-slugs: |
30+
[
31+
"kic",
32+
"nginx-docs"
33+
]
34+
github-token: ${{ secrets.NGINX_PAT }}
2535

2636
- name: Set release branch variable
2737
id: branch
38+
env:
39+
comment_body: ${{ github.event.comment.body }}
2840
run: |
29-
branch=$(git branch -a | egrep '^\s+remotes/origin/release' | awk '{print $1}' | sort -u | tail -n 1)
30-
release_branch=$(basename ${branch})
31-
echo "branch=${release_branch}" >> $GITHUB_OUTPUT
32-
cat $GITHUB_OUTPUT
41+
regex="/cherry-pick to (release-[2-9]+\.[0-9]+)"
42+
if [[ "${comment_body}" =~ $regex ]]; then
43+
branch=${BASH_REMATCH[1]}
44+
if git branch -a | egrep '^\s+remotes/origin/release' | grep -q "${branch}"; then
45+
echo "branch=${branch}" >> $GITHUB_OUTPUT
46+
else
47+
echo "branch=" >> $GITHUB_OUTPUT
48+
fi
49+
fi
3350
3451
- name: Cherry pick into ${{ steps.branch.outputs.branch }}
52+
if: ${{ steps.branch.outputs.branch }}
3553
uses: carloscastrojumo/github-cherry-pick-action@503773289f4a459069c832dc628826685b75b4b3 # v1.0.10
3654
with:
3755
branch: ${{ steps.branch.outputs.branch }}

0 commit comments

Comments
 (0)