Skip to content

Merge pull request #11 from EnderModuBot/bug/10-issue-erstellung-hat-… #7

Merge pull request #11 from EnderModuBot/bug/10-issue-erstellung-hat-…

Merge pull request #11 from EnderModuBot/bug/10-issue-erstellung-hat-… #7

Workflow file for this run

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: Create issue to enable repository merge settings
run: |
owner_repo="${{ github.repository }}"
issue_title="Enable repository merge settings"
issue_body=$(
echo -e "Please go to [repository settings](https://github.com/${owner_repo}/settings#merge-button-settings) and configure the following:\n\n- [ ] Automatically delete head branches\n- [ ] Allow auto-merge"
)
curl -s -X POST \
-H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
-H "Accept: application/vnd.github+json" \
-d "{\"title\":\"$issue_title\",\"body\":\"$issue_body\"}" \
"https://api.github.com/repos/${owner_repo}/issues"
- 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 .github/workflows/setup.yml
git commit -m "chore: remove setup workflow"
git push