Skip to content

Commit 96615f7

Browse files
committed
added new job prepare-labels
1 parent 4d41ccb commit 96615f7

1 file changed

Lines changed: 31 additions & 1 deletion

File tree

.github/workflows/backport-assistant.yml

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,35 @@ on:
1616
- 'release/*.*.x'
1717

1818
jobs:
19+
prepare-labels:
20+
# Only run if 'backport/all' is present on a merged PR
21+
if: github.event.pull_request.merged && contains(github.event.pull_request.labels.*.name, 'backport/all')
22+
runs-on: ubuntu-latest
23+
steps:
24+
- name: Checkout code
25+
uses: actions/checkout@v4
26+
27+
- name: Extract Versions and Apply Labels
28+
env:
29+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
30+
PR_NUMBER: ${{ github.event.pull_request.number }}
31+
run: |
32+
# 1. Extract version numbers from the HCL file (assuming file is named 'versions.hcl')
33+
# This looks for lines like: version "1.22" {
34+
# And extracts: 1.22
35+
VERSIONS=$(grep -oE 'version "[0-9]+\.[0-9]+"' .release/versions.hcl | cut -d'"' -f2)
36+
37+
if [ -z "$VERSIONS" ]; then
38+
echo "No versions found in file. Exiting."
39+
exit 1
40+
fi
41+
42+
# 2. Loop through and apply labels
43+
for v in $VERSIONS; do
44+
echo "Processing version: $v"
45+
gh pr edit $PR_NUMBER --add-label "backport/$v"
46+
gh pr edit $PR_NUMBER --add-label "backport/ent/$v"
47+
done
1948
backport:
2049
if: github.event.pull_request.merged
2150
runs-on: ubuntu-latest
@@ -31,7 +60,8 @@ jobs:
3160
GITHUB_TOKEN: ${{ secrets.ELEVATED_GITHUB_TOKEN_WORKFLOW }}
3261
ENABLE_VERSION_MANIFESTS: true
3362
backport-ent:
34-
if: github.event.pull_request.merged && contains(join(github.event.pull_request.labels.*.name), 'backport/ent')
63+
if: github.event.pull_request.merged && (contains(join(github.event.pull_request.labels.*.name), 'backport/ent') ||
64+
contains(join(github.event.pull_request.labels.*.name), 'backport/all'))
3565
runs-on: ubuntu-latest
3666
steps:
3767
- name: Trigger backport for Enterprise

0 commit comments

Comments
 (0)