Skip to content

Latest commit

 

History

History
70 lines (48 loc) · 2.09 KB

README.md

File metadata and controls

70 lines (48 loc) · 2.09 KB

Github Action Lock Branch

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.

Usage

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

Token Requirements

The token must be a token with Write permissions for Administration.

  1. Go to Settings.
  1. Go to Developer Settings.
  1. Go to Personal Access Tokens -> Fine Grained Tokens.
  1. Set Administration to Read/Write.