Skip to content

Latest commit

 

History

History
48 lines (34 loc) · 1.27 KB

readme.md

File metadata and controls

48 lines (34 loc) · 1.27 KB

Check Base Branch

check-base-branch validates that pull requests are opened against allowed branches, failing the check or updating the base branch if not.

Usage

Failing the check

In `.github/workflows/main.yml:

name: Example Workflow

on: [pull_request]

jobs:
  check-base-branch:
    steps:
      - uses: a-b-r-o-w-n/[email protected]
        with:
          repo-token: "${{ secrets.GITHUB_TOKEN }}"
          protected-branches: "main, production"

Updating the base branch

In `.github/workflows/main.yml:

name: Example Workflow

on: [pull_request]

jobs:
  check-base-branch:
    steps:
      - uses: a-b-r-o-w-n/[email protected]
        with:
          repo-token: "${{ secrets.GITHUB_TOKEN }}"
          protected-branches: "main, production"
          default-branch: "dev"
          update-branch: true

Inspiration

Some projects set a default branch to something other than their development branch. It is easy for contributors to unknowingly open pull requests against the default branch instead of the development branch. Sometimes this was missed for small changes and resulted in commits getting merged into the protected branch. This action was created to help maintainers catch this problem in an automated way.