45 lines
1.3 KiB
Bash
45 lines
1.3 KiB
Bash
#!/bin/bash
|
|
|
|
# Apply branch protections to all repositories
|
|
# Requires GITEA_TOKEN env var
|
|
|
|
REPOS=("hermes-agent" "the-nexus" "timmy-home" "timmy-config")
|
|
|
|
for repo in "${REPOS[@]}"
|
|
do
|
|
curl -X POST "https://forge.alexanderwhitestone.com/api/v1/repos/Timmy_Foundation/$repo/branches/main/protection" \
|
|
-H "Authorization: token $GITEA_TOKEN" \
|
|
-H "Content-Type: application/json" \
|
|
-d '{
|
|
"required_reviews": 1,
|
|
"dismiss_stale_reviews": true,
|
|
"block_force_push": true,
|
|
"block_deletions": true
|
|
}'
|
|
done
|
|
#!/bin/bash
|
|
|
|
# Gitea API credentials
|
|
GITEA_TOKEN="your-personal-access-token"
|
|
GITEA_API="https://forge.alexanderwhitestone.com/api/v1"
|
|
|
|
# Repos to protect
|
|
REPOS=("hermes-agent" "the-nexus" "timmy-home" "timmy-config")
|
|
|
|
for REPO in "${REPO[@]}"; do
|
|
echo "Configuring branch protection for $REPO..."
|
|
|
|
curl -X POST -H "Authorization: token $GITEA_TOKEN" \
|
|
-H "Content-Type: application/json" \
|
|
-d '{
|
|
"name": "main",
|
|
"require_pull_request": true,
|
|
"required_approvals": 1,
|
|
"dismiss_stale_approvals": true,
|
|
"required_status_checks": '"$(test "$REPO" = "hermes-agent" && echo "true" || echo "false")"',
|
|
"block_force_push": true,
|
|
"block_delete": true
|
|
}' \
|
|
"$GITEA_API/repos/Timmy_Foundation/$REPO/branch_protection"
|
|
done
|