diff --git a/.github/workflows/setup.yml b/.github/workflows/setup.yml index dd237ce..767d18e 100644 --- a/.github/workflows/setup.yml +++ b/.github/workflows/setup.yml @@ -10,6 +10,7 @@ on: permissions: contents: write + issues: write jobs: minimal-setup: @@ -20,14 +21,42 @@ jobs: - name: Checkout repository uses: actions/checkout@v4 - - name: Enable branch auto-deletion via API + - name: Enable branch auto-deletion run: | curl -s -X PATCH "https://api.github.com/repos/${{ github.repository }}" \ - -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \ - -H "Accept: application/vnd.github+json" \ - -d '{"delete_branch_on_merge":true}' - env: - GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \ + -H "Accept: application/vnd.github+json" \ + -d '{"delete_branch_on_merge":true}' + + - 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: |