Skip to content

Commit 01e5d5e

Browse files
authored
Merge pull request #6 from EnderModuBot/feat/4-die-labels-müssen-auch-noch-erstellt-werden-end
chore: update setup workflow to include issue permissions and enhance…
2 parents a4c2850 + e384752 commit 01e5d5e

1 file changed

Lines changed: 35 additions & 6 deletions

File tree

.github/workflows/setup.yml

Lines changed: 35 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ on:
1010

1111
permissions:
1212
contents: write
13+
issues: write
1314

1415
jobs:
1516
minimal-setup:
@@ -20,14 +21,42 @@ jobs:
2021
- name: Checkout repository
2122
uses: actions/checkout@v4
2223

23-
- name: Enable branch auto-deletion via API
24+
- name: Enable branch auto-deletion
2425
run: |
2526
curl -s -X PATCH "https://api.github.com/repos/${{ github.repository }}" \
26-
-H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
27-
-H "Accept: application/vnd.github+json" \
28-
-d '{"delete_branch_on_merge":true}'
29-
env:
30-
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
27+
-H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
28+
-H "Accept: application/vnd.github+json" \
29+
-d '{"delete_branch_on_merge":true}'
30+
31+
- name: Create / update default issue labels
32+
shell: bash
33+
run: |
34+
declare -A labels=(
35+
["breaking"]="d20f48:Breaking changes or backwards-incompatible updates"
36+
["feature"]="2ecc71:New functionality or enhancements"
37+
["maintenance"]="f39c12:Codebase cleanup or non-feature updates"
38+
["performance"]="f1c40f:Performance-related improvements"
39+
["tests"]="1abc9c:Adding or updating tests"
40+
)
41+
42+
for name in "${!labels[@]}"; do
43+
IFS=':' read -r color desc <<< "${labels[$name]}"
44+
45+
# Erstellt das Label, fällt bei 422 (already exists) zurück auf PATCH
46+
status=$(curl -s -o /dev/null -w "%{http_code}" -X POST \
47+
-H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
48+
-H "Accept: application/vnd.github+json" \
49+
-d "{\"name\":\"${name}\",\"color\":\"${color}\",\"description\":\"${desc}\"}" \
50+
"https://api.github.com/repos/${{ github.repository }}/labels")
51+
52+
if [ "$status" = "422" ]; then
53+
curl -s -X PATCH \
54+
-H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
55+
-H "Accept: application/vnd.github+json" \
56+
-d "{\"new_name\":\"${name}\",\"color\":\"${color}\",\"description\":\"${desc}\"}" \
57+
"https://api.github.com/repos/${{ github.repository }}/labels/${name}"
58+
fi
59+
done
3160
3261
- name: Delete this workflow file
3362
run: |

0 commit comments

Comments
 (0)