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

[BUG] Can't get all changed files after pushing new commit #639

Closed
3 tasks done
okorepanov opened this issue Sep 23, 2022 · 6 comments · Fixed by #654 or ZcashFoundation/zebra#5367
Closed
3 tasks done

[BUG] Can't get all changed files after pushing new commit #639

okorepanov opened this issue Sep 23, 2022 · 6 comments · Fixed by #654 or ZcashFoundation/zebra#5367
Labels
bug Something isn't working

Comments

@okorepanov
Copy link

Is there an existing issue for this?

  • I have searched the existing issues

Does this issue exist in the latest version?

  • I'm using the latest release

Describe the bug?

I want to get all changed files over entire PR after each push event (after adding new commit as well). But i always get changed files from the last commit only. I guess, that i am doing something wrong, so, could you please direct me in a right way

To Reproduce

name: Echo Pull Request

on:
push:
pull_request:

jobs:
echo:
runs-on: ubuntu-latest
name: Echo Changed Files
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0

  - name: Get changed files
    id: changed-files
    uses: tj-actions/changed-files@v29

  - name: List all changed files
    run: |
      for file in ${{ steps.changed-files.outputs.all_changed_files }}; do
        echo "$file was changed"
      done

What OS are you seeing the problem on?

ubuntu-latest or ubuntu-20.04

Expected behavior?

Expect to iterate over all changed files in a PR

Relevant log output

No response

Anything else?

No response

Code of Conduct

  • I agree to follow this project's Code of Conduct
@okorepanov okorepanov added the bug Something isn't working label Sep 23, 2022
@okorepanov okorepanov changed the title [BUG] <title> [BUG] Can't get all changed files after pushing new commit Sep 23, 2022
@github-actions
Copy link
Contributor

Thanks for reporting this issue, don't forget to star this project if you haven't already to help us reach a wider audience.

@jackton1
Copy link
Member

jackton1 commented Sep 23, 2022

@okorepanov To achieve that you’ll need to use.

name: CI

on:
  pull_request:
    branches:
      - main

jobs:
  build:
    runs-on: ubuntu-latest 
    name: Test changed-files
    steps:
      - uses: actions/checkout@v3
        with:
          fetch-depth: 0

      - name: Get changed files
        id: changed-files
        uses: tj-actions/changed-files@v29

      - name: List all changed files
        run: |
          for file in ${{ steps.changed-files.outputs.all_changed_files }}; do
            echo "$file was changed"
          done

You can also checkout the examples for more information.

The problem with why you only see changes between the last commit and the current commit is because you are running the workflow based on push events as well as using pull_request events the difference here is pretty subtle but one to consider.

push: Says trigger this workflow each time I push a commit. To get the diff between the main branch and the current commit you would need to configure the base_sha

This is counter intuitive because that’s the what using the pull_request event does by default.

pull_request: Says trigger this workflow based on changes to a pull request I.e pushing a new commit included. This would mean you compare changes using the last commit of the target branch of the pull request and the current pushed commit to the pull request.

Hope this helps. Let me know if you have any other questions.

@alpeb
Copy link

alpeb commented Sep 28, 2022

@jackton1 Could you please explain how did this work before in v29 for pull requests, without the need to fetch the entire repo's history?

@jackton1
Copy link
Member

@alpeb This worked previously because the target branch history was also pulled.

See: #654

I've decided to add this back since the checkout action doesn't have first-class support.

@jackton1
Copy link
Member

jackton1 commented Sep 29, 2022

@alpeb The fix has been deployed in the latest release.

@alpeb
Copy link

alpeb commented Sep 29, 2022

That's cool, thanks a lot!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
3 participants