Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Filter files for a PR based on changes since the last commit #136

Open
lleewwiiss opened this issue May 5, 2022 · 13 comments
Open

Filter files for a PR based on changes since the last commit #136

lleewwiiss opened this issue May 5, 2022 · 13 comments

Comments

@lleewwiiss
Copy link

lleewwiiss commented May 5, 2022

I have been using the package to run specific actions based on changes against the base branch, but to avoid the actions running every single push I was wondering if it was possible to run only based on the previous commit for a PR.

Example workflow:

  • New PR is created
  • Changes detected against base branch run actions
  • Push new commit
  • No changes detected since the last commit for specific filter skip steps as normal with the if condition

I've tried adding but it seems to get ignored:

base: '${{ github.event.pull_request.head.sha }}'
ref: '${{ github.event.pull_request.head.sha }}'

Is this functionality possible or for pull requests it can only work based on changes against the base branch?

@WardenDrew
Copy link

Seconding this. The ability to filter during a synchronize differently then we do during an opened PR event would be nice!

@basickarl
Copy link

basickarl commented Oct 12, 2022

Exactly what we are looking for as well.

@Superskyyy
Copy link

Really need this, but seems the added PR is not merged for a long time.

@ChipWolf
Copy link

Also need this

@pragmaticivan
Copy link

Is anyone working on that feature?

@Superskyyy
Copy link

Superskyyy commented Apr 27, 2023

Is anyone working on that feature?

I think it's implemented in #151, but it's not reviewed.

@pragmaticivan
Copy link

Because the issue is pretty old, I ended up using another action. Might move back if that gets fixed.

 - name: Get all changed tf file(s) or deploy workflow changes
    id: changes
    uses: tj-actions/changed-files@v35
    with:
      since_last_remote_commit: "true"
      files: |
        _files_

@Superskyyy
Copy link

Superskyyy commented Apr 27, 2023

Because the issue is pretty old, I ended up using another action. Might move back if that gets fixed.

 - name: Get all changed tf file(s) or deploy workflow changes
    id: changes
    uses: tj-actions/changed-files@v35
    with:
      since_last_remote_commit: "true"
      files: |
        _files_

WoW thanks a lot, I didn't notice this project before. @pragmaticivan is there anything that cannot be achieved vs path-filter?

@pragmaticivan
Copy link

Because the issue is pretty old, I ended up using another action. Might move back if that gets fixed.

 - name: Get all changed tf file(s) or deploy workflow changes
    id: changes
    uses: tj-actions/changed-files@v35
    with:
      since_last_remote_commit: "true"
      files: |
        _files_

WoW thanks a lot, I didn't notice this project before. @pragmaticivan is there anything that cannot be achieved vs path-filter?

afaik this other action has way more inputs and outputs. Nothing I could notice.

@Superskyyy
Copy link

Because the issue is pretty old, I ended up using another action. Might move back if that gets fixed.

 - name: Get all changed tf file(s) or deploy workflow changes
    id: changes
    uses: tj-actions/changed-files@v35
    with:
      since_last_remote_commit: "true"
      files: |
        _files_

WoW thanks a lot, I didn't notice this project before. @pragmaticivan is there anything that cannot be achieved vs path-filter?

afaik this other action has way more inputs and outputs. Nothing I could notice.

Thanks a lot! I will try this out.

@aldenquimby
Copy link

aldenquimby commented May 11, 2023

#190 should fix this. My team is using this successfully if you'd like to try it:

uses: aldenquimby/paths-filter@0f9f8bf7d2c3f9b9046e7bf16096464812c69650

@Superskyyy
Copy link

Superskyyy commented May 15, 2023

@aldenquimby What if last commit (commit1) failed but this commit (commit2) didn't do anything real to fix it (say just changed a .md file), will that lead to a workflow pass due to some checks are skipped? (but actually it should never pass). In this case, I imagine a fully safe approach will be checking a commit against the last fully ran check.

@aldenquimby
Copy link

aldenquimby commented May 15, 2023

@Superskyyy you are correct. In most cases, the default PR workflow described here is what you'll want, and you don't need any special config. This is what my team uses for all of our PRs.

We only ran into an issue on an edge case where we need to diff between a tag and the latest commit on a PR. So it's not the same problem as #136 , but it does have the same solution (allowing custom base + ref on PRs), and I added both as examples in the README on #190

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants