'GitHub Actions Status Check Pending

I have a GitHub required status check which gets executed every time a PR is opened/edited/reopened/synchronized to master.

The action itself gets executed successfully, however in the PR window, the check remains forever pending: Expected — Waiting for status to be reported

enter image description here

I have only 1 status check (to simplify the scenario to reproduce the case) and which is checked in the Branch policies for master. There are no other action workflows defined.

My script is:

name: ValidateFlow

on:
  pull_request:
    types: [opened, edited, reopened, synchronize]
    branches: 
      - master
env:
  GITHUB_PR_NUMBER: ${{github.event.pull_request.number}}
  
jobs:
  ValidateFlow:
    runs-on: ubuntu-latest
    
    steps:
      - uses: actions/checkout@v2
      
      - name: Extract branch name
        run: echo "PR_Branch_Name=${{ github.head_ref }}" >> $GITHUB_ENV      
               
      - name: Write to a file
        run: |
                git config --global user.name "my_username"
                git config --global user.email "my_email"

                git fetch
                git checkout "${{ env.PR_Branch_Name }}"

                cd .github
                cat /dev/null > version

                echo 'V1' >> version

                git add version
                git diff-index --quiet HEAD || git commit -m 'Updating the file version'
                git push origin "${{ env.PR_Branch_Name }}"
            


Solution 1:[1]

Try adding a name to your workflow job:

jobs:
  ValidateFlow:
    name: ValidateFlow

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 SofienM