Skip to content

Commit 92bc7a1

Browse files
Copilotpetesramek
andauthored
feat(lock): replace bypass-users with bypass-admins boolean (enforce_admins)
Agent-Logs-Url: https://github.com/petesramek/polyline-algorithm-csharp/sessions/e51105dd-ac43-4905-980f-36a944d4cb10 Co-authored-by: petesramek <2333452+petesramek@users.noreply.github.com>
1 parent 7076131 commit 92bc7a1

1 file changed

Lines changed: 10 additions & 15 deletions

File tree

  • .github/actions/github/branch-protection/lock

.github/actions/github/branch-protection/lock/action.yml

Lines changed: 10 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name: 'Lock branch'
22
author: 'Pete Sramek'
3-
description: 'Apply branch protection to prevent direct pushes. Requires PRs with configurable approval count; optional bypass actors let trusted users merge without a review.'
3+
description: 'Apply branch protection to prevent direct pushes. Requires PRs with configurable approval count; admins can optionally bypass all restrictions.'
44
inputs:
55
branch:
66
description: 'Branch name to lock.'
@@ -20,10 +20,10 @@ inputs:
2020
description: 'When true, approved reviews are dismissed when new commits are pushed to the branch.'
2121
required: false
2222
default: 'true'
23-
bypass-users:
24-
description: 'Comma-separated list of GitHub user logins that are allowed to bypass pull request requirements (e.g. "petesramek,bot-user").'
23+
bypass-admins:
24+
description: 'When true, repository admins are exempt from all branch protection rules (enforce_admins is disabled). When false (default), admins are also subject to the rules.'
2525
required: false
26-
default: ''
26+
default: 'false'
2727

2828
runs:
2929
using: composite
@@ -33,28 +33,23 @@ runs:
3333
env:
3434
GH_TOKEN: ${{ inputs.token }}
3535
run: |
36-
BYPASS_USERS_JSON="[]"
37-
if [ -n "${{ inputs.bypass-users }}" ]; then
38-
BYPASS_USERS_JSON=$(echo "${{ inputs.bypass-users }}" | tr ',' '\n' | sed 's/^ *//;s/ *$//' | jq -R . | jq -s .)
36+
ENFORCE_ADMINS=true
37+
if [ '${{ inputs.bypass-admins }}' = 'true' ]; then
38+
ENFORCE_ADMINS=false
3939
fi
4040
4141
PAYLOAD=$(jq -n \
4242
--argjson review_count '${{ inputs.required-approving-review-count }}' \
4343
--argjson dismiss_stale '${{ inputs.dismiss-stale-reviews }}' \
44-
--argjson bypass_users "$BYPASS_USERS_JSON" \
44+
--argjson enforce_admins "$ENFORCE_ADMINS" \
4545
--argjson lock_branch '${{ inputs.lock-branch }}' \
4646
'{
4747
"required_status_checks": null,
48-
"enforce_admins": false,
48+
"enforce_admins": $enforce_admins,
4949
"required_pull_request_reviews": {
5050
"dismiss_stale_reviews": $dismiss_stale,
5151
"require_code_owner_reviews": false,
52-
"required_approving_review_count": $review_count,
53-
"bypass_pull_request_allowances": {
54-
"users": $bypass_users,
55-
"teams": [],
56-
"apps": []
57-
}
52+
"required_approving_review_count": $review_count
5853
},
5954
"restrictions": null,
6055
"allow_force_pushes": false,

0 commit comments

Comments
 (0)