Skip to content
You're viewing an older version of this GitHub Action. Do you want to see the latest version instead?
lock

GitHub Action

Branch Guard

v1

Branch Guard

lock

Branch Guard

Guards branches from merges when

Installation

Copy and paste the following snippet into your .yml file.

              

- name: Branch Guard

uses: cirrus-actions/branch-guard@v1

Learn more about this action in cirrus-actions/branch-guard

Choose a version

Block PR merges when Checks for target branches are failing

Create following .github/workflows/branch-guard.yml that will block PRs from merging when the latest Check Suite starts failing and unblock once it's passing again:

on:
  check_suite: # to update all PRs upon a Check Suite completion
    type: ['completed']
  pull_request: # to update newly open PRs
    type: ['opened']
  
name: Branch Guard
jobs:
  branch-guard:
    name: Branch Guard
    if: github.event.check_suite.head_branch == 'master' || github.event.pull_request.base.ref == 'master'
    runs-on: ubuntu-latest
    steps:
    - uses: cirrus-actions/branch-guard@v1
      with:
        appsToCheck: Cirrus CI # or any other App name (can be a comma separated list of names)
      env:
        GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}