Skip to content

Commit a108ab8

Browse files
committed
ci: Auto-apply 27.lts cherry-pick label to main PRs
Bug: 484351320
1 parent d886392 commit a108ab8

File tree

2 files changed

+42
-26
lines changed

2 files changed

+42
-26
lines changed
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# These labels are automatically applied when a PR is merged.
2+
'cp-27.lts':
3+
- changed-files:
4+
- any-glob-to-any-file: '**'

.github/workflows/label-cherry-pick.yaml

Lines changed: 38 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -6,44 +6,56 @@ on:
66
- labeled
77
- closed
88

9+
permissions:
10+
contents: read
11+
912
jobs:
1013
prepare_branch_list:
1114
runs-on: ubuntu-latest
1215
if: |
1316
github.event.pull_request.merged == true &&
1417
github.event.pull_request.merge_commit_sha != null
18+
permissions:
19+
pull-requests: write
1520
outputs:
1621
target_branch: ${{ steps.set-branches.outputs.target_branch }}
1722
steps:
18-
- name: Set Branches
19-
id: set-branches
20-
env:
21-
PR_LABELS: ${{ toJson(github.event.pull_request.labels) }}
22-
EVENT_ACTION: ${{ github.event.action }}
23-
LABEL_NAME: ${{ github.event.label.name }}
24-
BASE_REF: ${{ github.base_ref }}
25-
run: |
26-
if [[ $EVENT_ACTION == 'closed' ]]; then
27-
# Get a list of the labels from the PR.
28-
labels=$(echo "$PR_LABELS" | jq -r '.[].name')
29-
else
30-
# Or get the label that was added on the merged PR.
31-
labels=$LABEL_NAME
32-
fi
23+
- name: Auto-label PR
24+
uses: actions/labeler@v5
25+
if: github.event.pull_request.merged == true && github.base_ref == 'main'
26+
with:
27+
repo-token: "${{ secrets.GITHUB_TOKEN }}"
28+
configuration-path: .github/config/infra/main_auto_cherry.yml
3329

34-
# This list must contain all cherry-pick destinations as file is used for all branches.
35-
branches=("main" "26.eap" "26.android" "25.lts.1+" "24.lts.1+" "23.lts.1+" "22.lts.1+" "21.lts.1+" "20.lts.1+" "19.lts.1+" "rc_11" "COBALT_9")
36-
filtered_branches=()
37-
for branch in "${branches[@]}"; do
38-
if [[ $branch == $BASE_REF ]]; then
39-
continue
40-
fi
41-
if [[ ${labels[@]} =~ "cp-$branch" ]]; then
42-
filtered_branches+=("$branch")
30+
- name: Set Branches
31+
id: set-branches
32+
env:
33+
PR_LABELS: ${{ toJson(github.event.pull_request.labels) }}
34+
EVENT_ACTION: ${{ github.event.action }}
35+
LABEL_NAME: ${{ github.event.label.name }}
36+
BASE_REF: ${{ github.base_ref }}
37+
run: |
38+
if [[ $EVENT_ACTION == 'closed' ]]; then
39+
# Get a list of the labels from the PR.
40+
labels=$(echo "$PR_LABELS" | jq -r '.[].name')
41+
else
42+
# Or get the label that was added on the merged PR.
43+
labels=$LABEL_NAME
4344
fi
44-
done
4545
46-
echo "target_branch=$(echo -n "${filtered_branches[@]}" | jq -cRs 'split(" ")')" >> $GITHUB_OUTPUT
46+
# This list must contain all cherry-pick destinations as file is used for all branches.
47+
branches=("main" "27.lts" "26.eap" "26.android" "25.lts.1+" "24.lts.1+" "23.lts.1+" "22.lts.1+" "21.lts.1+" "20.lts.1+" "19.lts.1+" "rc_11" "COBALT_9")
48+
filtered_branches=()
49+
for branch in "${branches[@]}"; do
50+
if [[ $branch == $BASE_REF ]]; then
51+
continue
52+
fi
53+
if [[ ${labels[@]} =~ "cp-$branch" ]]; then
54+
filtered_branches+=("$branch")
55+
fi
56+
done
57+
58+
echo "target_branch=$(echo -n "${filtered_branches[@]}" | jq -cRs 'split(" ")')" >> $GITHUB_OUTPUT
4759
4860
cherry_pick:
4961
runs-on: ubuntu-latest

0 commit comments

Comments
 (0)