'Github Action Status check missing from the list of checks in Protected branch settings

I have the following github action setup that triggers fine on creation of Pull Request. But it does not show up in the status checks list of protected branch (main). I'm not sure what I'm doing wrong.


name: Python application

on:
  pull_request:
    branches: [ main ]

jobs:
  build:

    runs-on: ubuntu-latest

    steps:
    - uses: actions/checkout@v1
    - name: Set up Python 3.7
      uses: actions/setup-python@v1
      with:
        python-version: 3.7
    - name: Install dependencies
      run: |
        python -m pip install --upgrade pip
    - name: Lint with flake8
      run: |
        pip install flake8
        # stop the build if there are Python syntax errors or undefined names
        flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
        # exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
        flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
    - name: GitHub Action for pylint
      uses: cclauss/[email protected]
    - name: Github Action for pytest
      run: python3 testing.py

I've also tried the same setting with:

on: [ pull_request ]

Edit: Screenshot of the check missing: enter image description here



Solution 1:[1]

Finally figured this out. I did not set a name for the job, so it defaulted to the property build in this case. I was searching by workflow name. Once I added the job name, I was able to search for it correctly. Later I also verified that searching for build brings up the check name in the list too.

jobs:
  build:
    name: python test
...

Solution 2:[2]

One possible avenue to explorer would be to add the action commit-status-updater in order to set yourself the status check you want.

A simple Github Action that allows us to update the status of a commit.

GitHub does not update the status of a commit when running workflow and therefore tools that rely on the context/status of a given commit are not compatible with it.

Currently the action supports pull_request and push events:

  • When the event is pull_request, the action will set the status to the last commit in the pull request at the moment the workflow was triggered.
  • When the event is push, the action will set the status to the last commit pushed at the moment the workflow was triggered.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Ankit
Solution 2 VonC