Skip to content

Commit d1abf7f

Browse files
committed
ci: Push labels to PR title
1 parent dd61281 commit d1abf7f

File tree

2 files changed

+26
-2
lines changed

2 files changed

+26
-2
lines changed

.github/labeler.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# SPDX-FileCopyrightText: (C) 2025 Intel Corporation
22
# SPDX-License-Identifier: Apache-2.0
33

4-
CI 🤖:
4+
CI🤖:
55
- changed-files:
66
- any-glob-to-any-file: ".github/**"
77

.github/workflows/auto-add-labels.yml

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,28 @@ jobs:
1515
label:
1616
runs-on: ubuntu-latest
1717
steps:
18-
- uses: actions/labeler@v5
18+
- uses: actions/checkout@v4
19+
- name: "Push labels"
20+
id: labeler
21+
uses: actions/labeler@v5
22+
- name: "Push labels to PR title"
23+
if: steps.labeler.outputs.all-labels != ''
24+
shell: bash
25+
run: |
26+
valid_labels="CI🤖|root|infra-core|infra-external|infra-manager|infra-onboarding"
27+
28+
labels=$(echo "${{ steps.labeler.outputs.all-labels }}" | grep -oE "$valid_labels" | tr '\n' ',' | sed 's/,$//')
29+
old_pr_title="${{ github.event.pull_request.title }}"
30+
new_pr_title=$(echo "$old_pr_title" | sed -n 's/^\[\([^]]*\)\] *//p')
31+
if [ -z "$new_pr_title" ]; then
32+
new_pr_title="$old_pr_title"
33+
fi
34+
new_pr_title="[$labels] ${new_pr_title}"
35+
echo "Labels: $labels"
36+
echo "Old PR title: $old_pr_title"
37+
echo "New PR title: $new_pr_title"
38+
curl -s -X PATCH \
39+
-H "Authorization: Bearer ${{ secrets.SYS_ORCH_GITHUB }}" \
40+
-H "Accept: application/vnd.github.v3+json" \
41+
"https://api.github.com/repos/${{ github.repository }}/pulls/${{ github.event.pull_request.number }}" \
42+
-d '{"title": "'"$new_pr_title"'"}' > /dev/null

0 commit comments

Comments
 (0)