runner icon indicating copy to clipboard operation
runner copied to clipboard

on.pull_request.paths-ignore are not respected correctly

Open GRBurst opened this issue 2 years ago • 18 comments

Describe the bug

According to the documentation we can use paths-ignore in the same way for pull_request events as we can do for push events on.<push|pull_request|pull_request_target>.<paths|paths-ignore>.

However, if we define a workflow like the following, the behavior differs:

name: Echo Date

on:
  push:
    paths-ignore:
      - 'README.md'
  pull_request:
    types: [opened, synchronize]
    paths-ignore:
      - 'README.md'

jobs:
  echo-date:
    runs-on: ubuntu-latest
    name: "Echo"

    steps:
      - name: Run echo date
        run: |
          echo -e "Hello at $(date -I)"

Although it seems to be working at the beginning when I (1) created a pr, (2) pushed a change on README.md and (3) nothing triggered, the behavior changed as soon as one commit of the pr references a file outside of the paths-ignore list. After a change to a file outside of the paths-ignore list, all following commits trigger the workflow.

Someone else mentioned a problem here as well: https://github.com/actions/runner/issues/545#issuecomment-1321467176

To Reproduce You can find a minimal example here: https://github.com/GRBurst/pull_requests.paths

Steps to reproduce the behavior:

  1. Create an action as above (or fork the example)
  2. Create a new branch and a pr
  3. Add commits, where at least one commit changes a file outside the paths-ignore declaration
  4. Check that all following commits trigger the workflow (the pull_request events triggers, the push does not).

Expected behavior I expect that the conditions to run the actions only take the last commit into account. So if I have commit that changes a file outside the path definition, it triggers the workflow. If a following commit does only changes to files declared in the paths-ignore list, the workflow should not trigger.

Runner Version and Platform

Version of your runner? -> 2.299.1

OS of the machine running the runner? OSX/Windows/Linux/... -> Ubuntu, 22.04.1, LTS

GRBurst avatar Dec 19 '22 12:12 GRBurst

Can confirm the bug

rene-hermenau avatar Jan 09 '23 16:01 rene-hermenau

Confirmed when trying this Github suggested solution in the troubleshooting docs: https://docs.github.com/en/repositories/configuring-branches-and-merges-in-your-repository/defining-the-mergeability-of-pull-requests/troubleshooting-required-status-checks

nickfujita avatar Feb 15 '23 10:02 nickfujita

I also confirm this bug.

ShutdownRepo avatar Feb 23 '23 22:02 ShutdownRepo

I can also confirm the bug:

Workflow: https://github.com/zdenko-kovac/testing/blob/main/.github/workflows/testPR.yaml PR with 3 commits: https://github.com/zdenko-kovac/testing/pull/2

where:

  • initial README.md update didn't trigger the WF (correct)
  • update of the WF itself (outside of paths-ignore): triggered the WF (correct)
  • additional update of README.md triggered the wf (wrong)

zdenko-kovac avatar Apr 26 '23 09:04 zdenko-kovac

It's been half a year, any news on this?

kingthorin avatar Jul 04 '23 16:07 kingthorin

as a work around you can make :

  pull_request:
     paths:
       - '!docs/**'
       - '.github/**'

ilyesAj avatar Aug 28 '23 14:08 ilyesAj

Is there an update on this issue? Has anyone developed a workaround?

mmulligan03 avatar Aug 29 '23 18:08 mmulligan03

It seems pull_request.paths affected too.

pavetok avatar Aug 31 '23 06:08 pavetok

Is there an update on this issue? Has anyone developed a workaround?

@ilyesAj's workaround to negate paths patterns didn't work for me. I tried it the way they wrote it, and I tried it like this because the workflow syntax reference indicates that negations may only subtract from selected paths. The result of both workaround attempts was that no pull request event types triggered the workflow irrespective of change objects matching the paths filter patterns.

  pull_request:
     paths:
       - '**'
       - '!docs/**'
       - '.github/**'

qrkourier avatar Aug 31 '23 11:08 qrkourier

Also, I have a similar issue in my project. Paths working for 'push' but not working for 'pull_requests' This workflow always runs when new changes are added in a pull request regardless of the changed path

on: push: branches: ["refactoring/move-to-separate-solutions"] paths: - "TwitPoster.EmailSender/" pull_request: branches: ["master"] paths: - "TwitPoster.EmailSender/"

wallyrion avatar Sep 01 '23 10:09 wallyrion

According to this explanation https://github.com/orgs/community/discussions/25161#discussioncomment-3246673 this "bug" is by design. Apparently when we make the on: pull-request actions, it will automatically use the synchronize event which will always consider all commits of a file change.

Although understandable, I think what we're missing here is a different implementation of the on: pull request functionality. If we had something like:

on:
  pull_request:
    types: [pushed]

Perhaps the pushed event could work differently than the synchronize event and thus not creating a huge breaking change effect. This way we could have a setup where we only run GH Actions based on pull requests events that includes a push of a commit, but also offers path filters on the most recent commit only. After all, if I have a deployment action and I'm only changing docs file, it doesn't matter that previous commits made changes to the real code, I still don't want to re-run all my deployment and pay for GH Actions when there's clearly no functionality change.

deleugpn avatar Sep 01 '23 21:09 deleugpn

I have a similar issue. I have defined a workflow with the following:

name: Update Documentation
on: 
  push:
    paths-ignore: 
      - '.github/workflows/**'
      - "!**.md"
  pull_request:
    paths-ignore: 
        - '.github/workflows/**'
        - "!**.md"

When I push a change of the yaml that contains this code it doesn't execute. This is expected. Then I made a change to "samples/chaincode/echo-go/chaincode/echo.go" and pushed it and the workflow did run. I understand that it shouldn't have since the "!**.md" would have been true, right?

munapower avatar Feb 06 '24 21:02 munapower

Me too. I have the same bug. The paths-ignore does not work. The flow always run unexpectedly.

khiemthanhicario avatar Jul 05 '24 08:07 khiemthanhicario