Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
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
4 changes: 4 additions & 0 deletions .github/config/infra/main_auto_cherry.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# These labels are automatically applied when a PR is merged.
'cp-27.lts':
- changed-files:
- any-glob-to-any-file: '**'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Using any-glob-to-any-file: '**' will apply the label to any change, which might be overly broad. If the intention is to only apply this label to changes that are relevant for cherry-picking to 27.lts.1+, consider a more specific glob pattern. For example, if only changes within a certain directory or with a specific file extension are relevant, the glob should reflect that. If the intent is truly for all files, then this is acceptable, but it's worth double-checking the scope.

64 changes: 38 additions & 26 deletions .github/workflows/label-cherry-pick.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,44 +6,56 @@
- labeled
- closed

permissions:
contents: read

jobs:
prepare_branch_list:
runs-on: ubuntu-latest
if: |
github.event.pull_request.merged == true &&
github.event.pull_request.merge_commit_sha != null
permissions:
pull-requests: write
outputs:
target_branch: ${{ steps.set-branches.outputs.target_branch }}
steps:
- name: Set Branches
id: set-branches
env:
PR_LABELS: ${{ toJson(github.event.pull_request.labels) }}
EVENT_ACTION: ${{ github.event.action }}
LABEL_NAME: ${{ github.event.label.name }}
BASE_REF: ${{ github.base_ref }}
run: |
if [[ $EVENT_ACTION == 'closed' ]]; then
# Get a list of the labels from the PR.
labels=$(echo "$PR_LABELS" | jq -r '.[].name')
else
# Or get the label that was added on the merged PR.
labels=$LABEL_NAME
fi
- name: Auto-label PR
uses: actions/labeler@v5

Check warning

Code scanning / Scorecard

Pinned-Dependencies Medium

score is 0: GitHub-owned GitHubAction not pinned by hash
Click Remediation section below to solve this issue
if: github.event.pull_request.merged == true && github.base_ref == 'main'
with:
repo-token: "${{ secrets.GITHUB_TOKEN }}"
configuration-path: .github/config/infra/main_auto_cherry.yml

# This list must contain all cherry-pick destinations as file is used for all branches.
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")
filtered_branches=()
for branch in "${branches[@]}"; do
if [[ $branch == $BASE_REF ]]; then
continue
fi
if [[ ${labels[@]} =~ "cp-$branch" ]]; then
filtered_branches+=("$branch")
- name: Set Branches
id: set-branches
env:
PR_LABELS: ${{ toJson(github.event.pull_request.labels) }}
EVENT_ACTION: ${{ github.event.action }}
LABEL_NAME: ${{ github.event.label.name }}
BASE_REF: ${{ github.base_ref }}
run: |
if [[ $EVENT_ACTION == 'closed' ]]; then
# Get a list of the labels from the PR.
labels=$(echo "$PR_LABELS" | jq -r '.[].name')
else
# Or get the label that was added on the merged PR.
labels=$LABEL_NAME
fi
done

echo "target_branch=$(echo -n "${filtered_branches[@]}" | jq -cRs 'split(" ")')" >> $GITHUB_OUTPUT
# This list must contain all cherry-pick destinations as file is used for all branches.
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")
filtered_branches=()
for branch in "${branches[@]}"; do
if [[ $branch == $BASE_REF ]]; then
continue
fi
if [[ ${labels[@]} =~ "cp-$branch" ]]; then
filtered_branches+=("$branch")
fi
done

echo "target_branch=$(echo -n "${filtered_branches[@]}" | jq -cRs 'split(" ")')" >> $GITHUB_OUTPUT

cherry_pick:
runs-on: ubuntu-latest
Expand Down
Loading