`paths-ignore:` not working for base level files?

Hey Everyone,

I’m trying to prevent my workflows from running ( in ./github/workflows) if the only change is to the CHANGELOG.md file.

I believe this should work. I’ve tried a few different version, but based on research in other threads I think this implementation should be working

on:
  pull_request:
    paths-ignore:
      - 'CHANGELOG.md'

When I push a change to a branch that has a active PR, it re-runs all my workflows, even tho the only change was to the changelog.

Any advice here would be greatly appreciated.

Thanks ahead of time.

Hi @lasvad , 

Is there only one file change (CHANGELOG.md) in your Pull Request Files Changed tab?  

If there are other files changed, when you push to source branch, there will be a synchronize type pull_request event. The GITHUB_REF of pull-request event is PR merge branch refs/pull/:prNumber/merge , and GITHUB_SHA is the last merge commit on the GITHUB_REF branch not the commit you pushed to source branch.  

If the merge commits on the GITHUB_REF branch include files except CHANGELOG.md , no matter which file changed in the commit you pushed to source branch, the workflow on pull request event with path-ignore will be triggered. 

Thank you for your response @yanjingzhu 

I believe I understand what your saying, but perhaps a quick summary of what my intended use case might help solidify my understanding.

My intended use case is…

  1. Add functionality to local branch.

  2. Push to remote branch.

  3. Open PR, github actions start.

  4. Github actions all pass.

  5. Add to changelog and push. <— on this step, I would like the github actions to be ignored, and remain “Passed”. As the only change was to the changelog, we don’t need our unit tests ran again.

Is this possible?

Based on your explaination, the paths-ignore check is not on the specific commit I push up, but on the entire PR as a whole.

Thank you,

There is a workaround for step 5. You need to add an additional job to check file changes of the current pushed commit. Then if only CHANGELOG.md is changed , then skip next jobs. There is a sample workflow :

on:
  pull_request:

jobs:
  check-changes:
    runs-on: ubuntu-latest
    outputs:
      continue: ${{steps.changefile.outputs.continue}}
    steps:
    - uses: actions/checkout@v1
    - name: file changes
      id: changefile
      run: |
        changed_file=$(git diff-tree --no-commit-id --name-only -r ${{ github.event.before }} ${{github.event.after}})
        file_count=$(git diff-tree --no-commit-id --name-only -r ${{ github.event.before }} ${{github.event.after}} | wc -l )
        if [[$changed_file == 'CHANGELOG.md' && $file_count == 1]]
        then
          echo ::set-output name=continue::false
        else
          echo ::set-output name=continue::true
        fi
  build:
# your original jobs
     runs-on: ubuntu-latest
     needs: [check-changes]
     if: needs.check-changes.outputs.continue == 'true'
     steps:
     - run: echo hello

Please remember to use actions/checkout@v1 to get all the branches history. And you need to add needs and if conditional to next jobs. 

needs: [check-changes]
if: needs.check-changes.outputs.continue == 'true'