This Github Action locks or unlocks a branch using Branch Protection Rules.
It is useful for automating the locking of a branch, particularly when paired with Github Action Scheduler.
You can find a working demo in .github/workflows/demo.yml.
Here is a demo for locking a branch.
- name: Lock branch
id: lock
uses: JustinDFuller/github-action-lock-branch@v1
with:
lock: true ## required
token: ${{ secrets.LOCK_TOKEN }} # required
owner: JustinDFuller # optional
repository: github-action-lock-branch # optional
branch: main # optional
Here is a demo for unlocking a branch.
- name: Lock branch
id: lock
uses: JustinDFuller/github-action-lock-branch@v1
with:
lock: false ## required
token: ${{ secrets.LOCK_TOKEN }} # required
owner: JustinDFuller # optional
repository: github-action-lock-branch # optional
branch: main # optional
Here is a demo for inferring the current owner, repo, and branch.
- name: Lock branch
id: lock
uses: JustinDFuller/github-action-lock-branch@v1
with:
lock: false ## required
token: ${{ secrets.LOCK_TOKEN }} # required
The token
must be a token with Write
permissions for Administration
.
- Go to
Settings
.

- Go to
Developer Settings
.

- Go to
Personal Access Tokens
->Fine Grained Tokens
.

- Set
Administration
toRead/Write
.
