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

failed to Get list of files on pull request merge #414

Closed
3 tasks done
rajeshwer opened this issue Mar 4, 2022 · 2 comments
Closed
3 tasks done

failed to Get list of files on pull request merge #414

rajeshwer opened this issue Mar 4, 2022 · 2 comments
Labels
bug Something isn't working

Comments

@rajeshwer
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?

Hello
I am trying to get the name of the file added after pull request is merged
below is my work flow which i am currently using

name: CI

on:
  push:
    branches: [poc]
  pull_request:
    branches: [poc]
    types: [opened, synchronize, edited, closed]
jobs:
  build:
    runs-on: ubuntu-latest
    name: Test changed-files
    steps:
      - uses: actions/checkout@v2
        with:
          fetch-depth: 0
      - name: Get specific changed files
        id: changed-files-specific
        uses: tj-actions/changed-files@v17.2
        with:
          files: |
            **/*.json
      - name: validate access.json file
        run: |
          cat  ${{ steps.changed-files-specific.outputs.all_changed_files }}|jq
      - name: Read access.json
        id: readAccessFile
        uses: juliangruber/read-file-action@v1
        with:
          path: ${{ steps.changed-files-specific.outputs.all_changed_files }}

It works a expected by listing the newly added file name and reading when pull request is raised and pull request status is open .
But when pull request is merged It is not working as expected .
Output of github actions :

Run bash $GITHUB_ACTION_PATH/entrypoint.sh
changed-files
  Resolving repository path...
  Retrieving changes between 307[82](https://github.com/myrepo/access/runs/5415320264?check_suite_focus=true#step:3:82)7b1f6e70f1f2ceb[92](https://github.com/myrepo/access/runs/5415320264?check_suite_focus=true#step:3:92)646800[94](https://github.com/myrepo/access/runs/5415320264?check_suite_focus=true#step:3:94)ffd610535d (security_poc) → 307827b1f6e70f1f2ceb9264680094ffd610535d (test1)
  Getting diff...
  Input files pattern: accessRequest/2022-02-23-12:04:54-0800-access.json|accessRequest/acc.json
  Added files: 
  Copied files: 
  Deleted files: 
  Modified files: 
  Renamed files: 
  Type Changed files: 
  Unmerged files: 
  Unknown files: 
  All changed and modified files: 
  All changed files: 
  All modified files:

I want it to work for all actions
pull_request:[opened, synchronize, edited, closed]

To Reproduce

use workflow which i am using .
create a pull request to any file in repo with extension .json.
Reading newly modified/added file name can be read.
but when the PR is merged unable to read the file name

  Getting diff...
  Input files pattern: accessRequest/2022-02-23-12:04:54-0800-access.json|accessRequest/acc.json
  Added files: 
  Copied files: 
  Deleted files: 
  Modified files: 
  Renamed files: 
  Type Changed files: 
  Unmerged files: 
  Unknown files: 
  All changed and modified files: 
  All changed files: 
  All modified files:

What OS are you seeing the problem on?

ubuntu-latest or ubuntu-20.04

Expected behavior?

Expecting to read the file name with extension **/*.json from pull request merge

Relevant log output

No response

Anything else?

No response

Code of Conduct

  • I agree to follow this project's Code of Conduct
@rajeshwer rajeshwer added the bug Something isn't working label Mar 4, 2022
@github-actions
Copy link
Contributor

github-actions bot commented Mar 4, 2022

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

@jackton1
Copy link
Member

jackton1 commented Mar 4, 2022

@rajeshwer Given that the PR branch would already be merged into the target/base branch the last SHA on the base branch would be the modified PR changes that's why you don't see any files.

There are two ways around this:

1 Using the push event on the target branch to find all files that have changed since the last remote commit on the target branch.

...
     - name: Get specific changed files
        id: changed-files-specific
        uses: tj-actions/changed-files@v17.2
        with:
          since_last_remote_commit: "true"
          files: |
            **/*.json
  1. Using the first commit of the PR as the reference for performing change detection. (NB: This would mean that the changes made in the first commit wouldn't be compared to the target branch)
     - name: Get specific changed files
        id: changed-files-specific
        uses: tj-actions/changed-files@v17.2
        with:
           base_sha: ${{ github.event.pull_request.base.sha }}
           files: |
            **/*.json

See: https://github.com/tj-actions/changed-files#example for more examples.

Confirmed using this branch chore: test pull_requests events runs:

Hope this helps

@jackton1 jackton1 closed this as completed Mar 4, 2022
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
Development

No branches or pull requests

2 participants