Skip to content
This repository has been archived by the owner on Mar 16, 2020. It is now read-only.

Action to guard branches from merges when any of the latest check suites or commit statuses is failing.

License

Notifications You must be signed in to change notification settings

cirrus-actions/branch-guard

Use this GitHub action with your project
Add this Action to an existing workflow or create a new one
View on Marketplace

Repository files navigation

Deprecated

In favor of a more suphesicated GitHub App. See https://github.com/cirruslabs/gh-submit-queue

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:
  pull_request: # to update newly open PRs or when a PR is synced
  check_suite: # to update all PRs upon a Check Suite completion
    type: ['completed']
  
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/[email protected]
      with:
        appsToCheck: Cirrus CI # or any other App name (can be a comma separated list of names)
      env:
        GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

Disclaimer: Action doesn't fully work on PRs from forks since GitHub Actions for such PRs have only read permissions and can't update the status checks. Please remove pull_request line from branch-guard.yml to mitigate the issue,

About

Action to guard branches from merges when any of the latest check suites or commit statuses is failing.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published