Skip to content

Commit 9709c59

Browse files
committed
Use rulesets to lock branches when retiring a branch
1 parent 61b4f82 commit 9709c59

1 file changed

Lines changed: 5 additions & 2 deletions

File tree

.github/workflows/retire-branch.yml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -140,9 +140,12 @@ jobs:
140140
echo "Branch: $BRANCH"
141141
echo ""
142142
143-
# Look for an existing "Retired Branch Lock" ruleset on this repo.
143+
# Look for an existing repo-level ruleset with this name.
144+
# Filtering by source_type=="Repository" avoids matching org-level rulesets
145+
# (which also appear in this list but cannot be patched via the repo API).
144146
RULESET_ID=$(gh api "repos/${REPO}/rulesets" \
145-
| jq -r --arg name "$RULESET_NAME" '.[] | select(.name == $name) | .id')
147+
| jq -r --arg name "$RULESET_NAME" \
148+
'.[] | select(.name == $name and .source_type == "Repository") | .id')
146149
147150
if [[ -z "$RULESET_ID" ]]; then
148151
echo "No existing '${RULESET_NAME}' ruleset found — creating one."

0 commit comments

Comments
 (0)