How to enable a single Github action to not block a merge?

21 Views Asked by At

I'm currently running three separate tests suites on Github actions and it triggers when anyone creates or pushes to an open pull request. However, one of these actions contains tests for an upcoming feature that I want others to be aware of, for feedback, but I do not disable the merge button if it fails.

Is there anyway to ignore this just for a single action?

e.g.

GH Action 1 Test -> Pass
GH Action 2 Tests -> Pass
GH Action 3 Tests -> Fail

Merging is still allowed as GH Action 3 is configured to NOT disable the merge button.

1

There are 1 best solutions below

0
Todd Drinkwater On
  1. Go to the Settings tab in your repo.
  2. Click on the "Branches" tab in the side menu located under "Code and automation"
  3. Under Branch protection rules click "Add new rule" or edit and existing one.
  4. Select the "Require status checks to pass before merging" checkbox
  5. Search for your GH action job's name in the search bar labelled "Search for status checks in the last week in this repository" and select only the jobs that you wish to block merging shall it fail.

Note that inside your Github action workflow file you will need to have a name for the build step if you want it to show up in the search menu.

e.g.

name: Node.js CI
run-name: "Run Unit Tests"
on:
  push:
    branches: [ "main" ]
  pull_request:
    branches: [ "main" ]

jobs:
  build:
    name: Run Unit Tests <------ REQUIRED FOR BRANCH PROTECTION RULES
    runs-on: ubuntu-latest
    steps:
    - uses: actions/checkout@v4
    - name: Use Node.js
      uses: actions/setup-node@v4
      with:
        node-version: '18.0.0'
        cache: 'npm'
    - run: npm ci
    - run: npm test