Skip to content

Commit 829e428

Browse files
committed
I wonder if this works?
1 parent 1acc3aa commit 829e428

File tree

2 files changed

+59
-80
lines changed

2 files changed

+59
-80
lines changed

.github/labels.yml

Lines changed: 42 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -1,56 +1,42 @@
1-
labels:
2-
- name: "bug"
3-
color: "#d73a4a"
4-
description: "Something isn't working"
5-
6-
- name: "documentation"
7-
color: "#0075ca"
8-
description: "Improvements or additions to documentation"
9-
10-
- name: "duplicate"
11-
color: "#cfd3d7"
12-
description: "This issue or pull request already exists"
13-
14-
- name: "enhancement"
15-
color: "#a2eeef"
16-
description: "New feature or request"
17-
18-
- name: "help wanted"
19-
color: "#008672"
20-
description: "Extra attention is needed"
21-
22-
- name: "question"
23-
color: "#d876e3"
24-
description: "Further information is requested"
25-
26-
- name: "wontfix"
27-
color: "#ffffff"
28-
description: "This will not be worked on"
29-
30-
- name: "Mcity"
31-
color: "#CED453"
32-
description: "This particularly affects Mcity testing"
33-
34-
- name: "Kcity"
35-
color: "#3E508D"
36-
description: "This particularly affects Kcity testing"
37-
38-
- name: "Simulation"
39-
color: "#DB4C81"
40-
description: "This particularly affects simulation testing"
41-
42-
- name: "Localization"
43-
color: "#6F3CFD"
44-
description: "This particularly affects the localization challenge"
45-
46-
- name: "99BOR"
47-
color: "#D0C35B"
48-
description: "This particularly affects the 99% buy off ride challenge (99BOR)"
49-
50-
- name: "DYOC"
51-
color: "#1AB65E"
52-
description: "This particularly affects the design your own challenge (DYOC)"
53-
54-
- name: "Safety Concern"
55-
color: "#FBCA04"
56-
description: "This poses a safety risk"
1+
bug:
2+
color: "d73a4a"
3+
description: "Something is not working"
4+
documentation:
5+
color: "0075ca"
6+
description: "Improvements or additions to documentation"
7+
duplicate:
8+
color: "cfd3d7"
9+
description: "This issue or pull request already exists"
10+
enhancement:
11+
color: "a2eeef"
12+
description: "New feature or request"
13+
help wanted:
14+
color: "008672"
15+
description: "Extra attention is needed"
16+
question:
17+
color: "d876e3"
18+
description: "Further information is requested"
19+
wontfix:
20+
color: "ffffff"
21+
description: "This will not be worked on"
22+
Mcity:
23+
color: "CED453"
24+
description: "This particularly affects Mcity testing"
25+
Kcity:
26+
color: "3E508D"
27+
description: "This particularly affects Kcity testing"
28+
Simulation:
29+
color: "DB4C81"
30+
description: "This particularly affects simulation testing"
31+
Localization:
32+
color: "6F3CFD"
33+
description: "This particularly affects the localization challenge"
34+
99BOR:
35+
color: "D0C35B"
36+
description: "This particularly affects the 99% buy off ride challenge (99BOR)"
37+
DYOC:
38+
color: "1AB65E"
39+
description: "This particularly affects the design your own challenge (DYOC)"
40+
Safety Concern:
41+
color: "FBCA04"
42+
description: "This poses a safety risk"

.github/workflows/update-labels.yml

Lines changed: 17 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ on:
55
branches:
66
- main
77
paths:
8-
- .github/labels.yml # Only trigger if the label configuration changes
8+
- .github/labels.yml
99

1010
jobs:
1111
update-labels:
@@ -22,42 +22,35 @@ jobs:
2222
- name: Install dependencies
2323
run: |
2424
python -m pip install --upgrade pip
25-
pip install requests yq
25+
pip install requests yq && sudo snap install yq
2626
2727
- name: Get all repos in the organization
28+
env:
29+
LABELS_PAT: ${{ secrets.LABELS_PAT }}
2830
id: get_repos
2931
run: |
3032
ORGANIZATION="queens-autodrive"
3133
RESPONSE=$(curl -s \
3234
-H "Authorization: token $LABELS_PAT" \
3335
"https://api.github.com/orgs/$ORGANIZATION/repos?per_page=100")
34-
echo "API Response: $RESPONSE"
3536
REPOS=$(echo "$RESPONSE" | jq -r '.[].name')
3637
echo "REPOS=$REPOS" >> $GITHUB_ENV
3738
- name: Update Labels for All Repos
3839
env:
39-
LABELS_PAT: ${{ secrets.LABELS_PAT }} # GitHub token for authentication
40+
LABELS_PAT: ${{ secrets.LABELS_PAT }}
4041
run: |
41-
LABELS=$(cat .github/labels.yml) # Path to your labels configuration file
42-
43-
# Loop through the repositories listed in the environment variable
44-
for REPO in $REPOS; do
42+
LABELS=$(cat .github/labels.yml)
43+
echo $REPOS
44+
echo "$REPOS" | while IFS= read -r REPO; do
4545
echo "Updating labels in $REPO"
46-
47-
# Loop through the labels and update them
48-
for LABEL in $(echo "$LABELS" | yq e '.labels[]' -); do
49-
# Extract label name and color from the YAML file
50-
LABEL_NAME=$(echo "$LABEL" | yq e '.name' -)
51-
LABEL_COLOR=$(echo "$LABEL" | yq e '.color' -)
52-
LABEL_DESCRIPTION=$(echo "$LABEL" | yq e '.description' -)
53-
54-
echo "Label: $LABEL_NAME, Color: $LABEL_COLOR, Description: $LABEL_DESCRIPTION" # Print label info
55-
56-
# Make the API request to update the label
57-
curl -X PUT \
58-
-H "Authorization: token $SELF_RUNNER_PAC" \
59-
-H "Accept: application/vnd.github.v3+json" \
60-
-d '{"name": "'"$LABEL_NAME"'", "color": "'"$LABEL_COLOR"'"}' \
61-
"https://api.github.com/repos/$ORGANIZATION/$REPO/labels/$LABEL_NAME"
46+
echo "$LABELS" | yq e 'to_entries | .[] | "\(.key): color: \(.value.color), description: \(.value.description)"' - | while IFS= read -r label; do
47+
LABEL_NAME=$(echo "$label" | awk -F": color" '{print $1}' | xargs | tr -d '\n')
48+
LABEL_COLOR=$(echo "$label" | awk -F"color: " '{print $2}' | awk -F", description" '{print $1}' | xargs | tr -d '\n')
49+
LABEL_DESCRIPTION=$(echo "$label" | awk -F"description: " '{print $2}' | xargs | tr -d '\n')
50+
curl -X POST \
51+
-H "Authorization: token $LABELS_PAT" \
52+
-H "Accept: application/vnd.github.v3+json" \
53+
-d '{"name": "'"$LABEL_NAME"'", "color": "'"$LABEL_COLOR"'", "description": "'"$LABEL_DESCRIPTION"'"}' \
54+
"https://api.github.com/repos/$ORGANIZATION/$REPO/labels"
6255
done
6356
done

0 commit comments

Comments
 (0)