#!/usr/bin/env bash # Setup GitHub branch protection and auto-merge for Dependabot # Repository: complexcaresolutions/cms.c2sgmbh # # Voraussetzungen: # - gh CLI installiert und authentifiziert (gh auth login) # - Admin-Rechte auf das Repository set -euo pipefail REPO="complexcaresolutions/cms.c2sgmbh" BRANCH="main" echo "=== GitHub Repository Setup für Dependabot ===" echo "Repository: $REPO" echo "Branch: $BRANCH" echo "" # 1. Prüfe gh CLI Auth echo "[1/4] Prüfe GitHub CLI Authentifizierung..." if ! gh auth status &>/dev/null; then echo "FEHLER: gh CLI nicht authentifiziert. Bitte 'gh auth login' ausführen." exit 1 fi echo " OK" # 2. Auto-Merge aktivieren echo "[2/4] Aktiviere Auto-Merge in Repository-Settings..." gh api "repos/$REPO" \ --method PATCH \ --field allow_auto_merge=true \ --silent echo " OK" # 3. Branch Protection setzen echo "[3/4] Setze Branch Protection auf '$BRANCH'..." gh api "repos/$REPO/branches/$BRANCH/protection" \ --method PUT \ --input - <<'EOF' { "required_status_checks": { "strict": true, "contexts": ["CI Success"] }, "enforce_admins": false, "required_pull_request_reviews": { "required_approving_review_count": 0, "dismiss_stale_reviews": false, "require_code_owner_reviews": false }, "restrictions": null, "allow_force_pushes": false, "allow_deletions": false } EOF echo " OK" # 4. Verifizierung echo "[4/4] Verifiziere Konfiguration..." echo "" echo "--- Auto-Merge ---" gh api "repos/$REPO" --jq '" allow_auto_merge: \(.allow_auto_merge)"' echo "" echo "--- Branch Protection ($BRANCH) ---" gh api "repos/$REPO/branches/$BRANCH/protection/required_status_checks" \ --jq '" strict: \(.strict)\n checks: \(.contexts | join(", "))"' echo "" echo "=== Setup abgeschlossen ===" echo "" echo "Nächste Schritte:" echo " - Dependabot erstellt ab morgen 04:00 automatisch PRs" echo " - Patch-Updates werden nach CI-Success auto-gemergt" echo " - Major/Minor-Updates erfordern manuelles Review"