You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: .github/actions/github/branch-protection/lock/action.yml
+44-19Lines changed: 44 additions & 19 deletions
Original file line number
Diff line number
Diff line change
@@ -1,6 +1,6 @@
1
1
name: 'Lock branch'
2
2
author: 'Pete Sramek'
3
-
description: 'Apply branch protection to prevent direct pushes. Requires PRs but no approvals (solo-maintainer friendly).'
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.'
4
4
inputs:
5
5
branch:
6
6
description: 'Branch name to lock.'
@@ -9,9 +9,21 @@ inputs:
9
9
description: 'GitHub token with administration:write (repo admin) permission. Use a PAT; GITHUB_TOKEN cannot call the branch protection API.'
10
10
required: true
11
11
lock-branch:
12
-
description: 'When true, sets lock_branch to prevent even PR merges (use during automated operations). When false (default), only direct pushes are blocked; PRs with required reviews can still be merged.'
12
+
description: 'When true, sets lock_branch to prevent even PR merges (use during automated operations). When false (default), only direct pushes are blocked; PRs can still be merged.'
13
13
required: false
14
14
default: 'false'
15
+
required-approving-review-count:
16
+
description: 'Number of approving reviews required before a PR can be merged. Set to 0 to require PRs without requiring approvals.'
17
+
required: false
18
+
default: '1'
19
+
dismiss-stale-reviews:
20
+
description: 'When true, approved reviews are dismissed when new commits are pushed to the branch.'
21
+
required: false
22
+
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").'
25
+
required: false
26
+
default: ''
15
27
16
28
runs:
17
29
using: composite
@@ -21,23 +33,36 @@ runs:
21
33
env:
22
34
GH_TOKEN: ${{ inputs.token }}
23
35
run: |
24
-
if ! gh api --method PUT /repos/${{ github.repository }}/branches/${{ inputs.branch }}/protection \
if ! echo "$PAYLOAD" | gh api --method PUT /repos/${{ github.repository }}/branches/${{ inputs.branch }}/protection --input -; then
41
66
echo "::error::Failed to apply branch protection to '${{ inputs.branch }}'. Ensure the token has 'administration: write' permission and the branch exists."
0 commit comments