-
Notifications
You must be signed in to change notification settings - Fork 0
76 lines (65 loc) · 2.63 KB
/
setup.yml
File metadata and controls
76 lines (65 loc) · 2.63 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
name: Initial Repository Setup
on:
push:
branches:
- main
- master
paths:
- '.github/workflows/setup.yml'
permissions:
contents: write
issues: write
jobs:
minimal-setup:
if: github.repository != 'EnderModuBot/template'
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Replace placeholders in issue template
env:
OWNER: ${{ github.repository_owner }}
REPO: ${{ github.event.repository.name }}
run: |
sed -i "s|{{owner}}|$OWNER|g" .github/setup-reminder.md
sed -i "s|{{repo}}|$REPO|g" .github/setup-reminder.md
- name: Create setup reminder issue
uses: JasonEtco/create-an-issue@v2
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
filename: .github/setup-reminder.md
- name: Create / update default issue labels
shell: bash
run: |
declare -A labels=(
["breaking"]="d20f48:Breaking changes or backwards-incompatible updates"
["feature"]="2ecc71:New functionality or enhancements"
["maintenance"]="f39c12:Codebase cleanup or non-feature updates"
["performance"]="f1c40f:Performance-related improvements"
["tests"]="1abc9c:Adding or updating tests"
)
for name in "${!labels[@]}"; do
IFS=':' read -r color desc <<< "${labels[$name]}"
# Erstellt das Label, fällt bei 422 (already exists) zurück auf PATCH
status=$(curl -s -o /dev/null -w "%{http_code}" -X POST \
-H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
-H "Accept: application/vnd.github+json" \
-d "{\"name\":\"${name}\",\"color\":\"${color}\",\"description\":\"${desc}\"}" \
"https://api.github.com/repos/${{ github.repository }}/labels")
if [ "$status" = "422" ]; then
curl -s -X PATCH \
-H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
-H "Accept: application/vnd.github+json" \
-d "{\"new_name\":\"${name}\",\"color\":\"${color}\",\"description\":\"${desc}\"}" \
"https://api.github.com/repos/${{ github.repository }}/labels/${name}"
fi
done
- name: Delete this workflow file
run: |
git config --global user.name "setup-bot"
git config --global user.email "setup@github.com"
git rm -f .github/workflows/setup.yml
git rm -f .github/setup-reminder.md
git commit -m "chore: remove setup workflow"
git push