-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup-layer-b.sh
More file actions
14 lines (14 loc) · 876 Bytes
/
Copy pathsetup-layer-b.sh
File metadata and controls
14 lines (14 loc) · 876 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
#!/usr/bin/env bash
# Arm Layer B: a branch ruleset (require PR, no force-push, no deletion) on the
# default branch, applied via gh api from .github/rulesets/main.json.
# Expected HTTP 403 on free private repos (rulesets need public or Pro): the
# rule is armed-in-code but inert here; default branch held by PR discipline.
set -euo pipefail
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
PAYLOAD="${SCRIPT_DIR}/../.github/rulesets/main.json"
command -v gh >/dev/null 2>&1 || { echo "ERROR: gh not found" >&2 ; exit 1 ; }
gh auth status >/dev/null 2>&1 || { echo "ERROR: gh not authenticated" >&2 ; exit 1 ; }
[ -f "${PAYLOAD}" ] || { echo "ERROR: payload missing: ${PAYLOAD}" >&2 ; exit 1 ; }
REPO="$(gh repo view --json nameWithOwner --jq .nameWithOwner)"
echo "Applying Layer B ruleset to: ${REPO}"
gh api "repos/${REPO}/rulesets" -X POST --input "${PAYLOAD}"