Giter VIP home page Giter VIP logo

get-changed-files's Introduction

jitterbit/get-changed-files status

Get All Changed Files

Get all of the files changed/modified in a pull request or push's commits. You can choose to get all changed files, only added files, only modified files, only removed files, only renamed files, or all added and modified files. These outputs are available via the steps output context. The steps output context exposes the output names all, added, modified, removed, renamed, and added_modified.

Usage

See action.yml

- uses: jitterbit/get-changed-files@v1
  with:
    # Format of the steps output context.
    # Can be 'space-delimited', 'csv', or 'json'.
    # Default: 'space-delimited'
    format: ''

Scenarios

Get all changed files as space-delimited

If there are any files with spaces in them, then this method won't work and the step will fail. Consider using one of the other formats if that's the case.

- id: files
  uses: jitterbit/get-changed-files@v1
- run: |
    for changed_file in ${{ steps.files.outputs.all }}; do
      echo "Do something with this ${changed_file}."
    done

Get all added and modified files as CSV

- id: files
  uses: jitterbit/get-changed-files@v1
  with:
    format: 'csv'
- run: |
    mapfile -d ',' -t added_modified_files < <(printf '%s,' '${{ steps.files.outputs.added_modified }}')
    for added_modified_file in "${added_modified_files[@]}"; do
      echo "Do something with this ${added_modified_file}."
    done

Get all removed files as JSON

- id: files
  uses: jitterbit/get-changed-files@v1
  with:
    format: 'json'
- run: |
    readarray -t removed_files <<<"$(jq -r '.[]' <<<'${{ steps.files.outputs.removed }}')"
    for removed_file in ${removed_files[@]}; do
      echo "Do something with this ${removed_file}."
    done

Install, Build, Lint, Test, and Package

Make sure to do the following before checking in any code changes.

$ yarn
$ yarn all

License

The scripts and documentation in this project are released under the MIT License

get-changed-files's People

Contributors

dependabot[bot] avatar sean-krail avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

get-changed-files's Issues

Error: a step cannot have both the `uses` and `run` keys

When trying to follow along with the example, I noticed that both the 'uses' and 'run' keys are present and copying that into a yml file, I get an error from GitHub that "a step cannot have both the uses and run keys".
Following the example exactly works, but not if the run component calls a command to run an external script.
It may be helpful to update documentation to show an example of e.g. calling a Node script.

The head commit for this pull_request event is not ahead of the base commit

I squashed a bunch of commits from my PR into one, and now the action is giving me a message:

##[error]The head commit for this pull_request event is not ahead of the base commit. Please submit an issue on this action's GitHub repo.
All: [".github/workflows/black.yml"]
Added: [".github/workflows/black.yml"]
Modified: []
Removed: []
Renamed: []
Added or modified: [".github/workflows/black.yml"]

The issue is that the base commit as such no longer exists because it was squashed. However, it appears that the changed files list is still correct. Does this error need to be raised? what needs to happen to handle squashed base/head commits?

Get the list of files changed/modified in a release

This is a very useful action.
As it says on the box, it gets all of the files changed/modified in a pull request or push's commits.

Is there any chance that we could get the same functionality to work with new releases?
As in, get the list of files changed/modified in a release since the previous release?

Thanks!

Use PR target branch head as the base commit

Is it possible to get a list of changed files between a pull request and the branch it targets? Currently the action returns the changes between commits within the same PR.

I would like to avoid the need to squash commits within the PR during code review, but still be able to get a list of all the changed files in the PR branch.

new feature - scan a set of paths

Hi there.

Is there a possibility we add support for specific paths scanning?

Example:

- id: files
  name: Get modified files
  uses: jitterbit/get-changed-files@v1
  paths:
    - tracked_files/
    - tracked_files_2/

IMHO it would be a great feature. Awesome project btw, thank you for sharing!

mv: unlink /bin/bash: Operation not permitted

In reference to #15, which worked until now I now get the error mv: unlink /bin/bash: Operation not permitted when installing bash via brew on macos.

reference: https://github.com/pbek/QOwnNotes/actions/runs/3470015669/jobs/5797697932#step:4:14

Run brew install bash
==> Downloading https://ghcr.io/v2/homebrew/core/bash/manifests/5.2.2
==> Downloading https://ghcr.io/v2/homebrew/core/bash/blobs/sha256:a844d150df53490c40bd3135dee39490494442e58301233770439849a44731e0
==> Downloading from https://pkg-containers.githubusercontent.com/ghcr1/blobs/sha256:a844d150df53490c40bd3135dee39490494442e58301233770439849a44731e0?se=2022-11-15T11%3A35%3A00Z&sig=xG8JHAgyuCZdbX8DcxB93x%2BUdXW0T1nISz%2Fa%2Fw%2BZ7g4%3D&sp=r&spr=https&sr=b&sv=2019-12-12
==> Pouring bash--5.2.2.monterey.bottle.tar.gz
๐Ÿบ  /usr/local/Cellar/bash/5.2.2: 162 files, 11.7MB
==> Running `brew cleanup bash`...
Disable this behaviour by setting HOMEBREW_NO_INSTALL_CLEANUP.
Hide these hints with HOMEBREW_NO_ENV_HINTS (see `man brew`).
mv: unlink /bin/bash: Operation not permitted
Error: Process completed with exit code 1.

Removing the bash install action didn't solve the issue for me, mapfile still doesn't seem to be in the macos image.

Error: Bad credentials

I am receiving a Bad credentials permissions error when trying to run this job. I've tried with both setting the token manually as seen below and without it (which uses the default value specified in action.yml ). Not exactly sure why this is failing as github.token (or GITHUB_TOKEN) is automatically defined when you add the GitHub action. I've checked the permissions in the repo and GITHUB_TOKEN is allowed read write permissions. Any assistance is appreciated.

Below is the workflow playbook.

name: Commit

# Controls when the workflow will run
on:
  # Triggers the workflow on pull request events but only for the master branch
  pull_request:
    types:
      - closed
          
jobs:
  #If Pull request is merged into the master branch
  changedfiles:
    if: github.event.pull_request.merged == true
    runs-on: [ self-hosted ]
    steps:
        - uses: jitterbit/get-changed-files@v1
          with:
            token: ${{ secrets.GITHUB_TOKEN }}
            format: 'json'

Is it possible to have field rename_from

I see list of files that were removed in Renamed:. These files are only final files. Would it be possible to get source files also? Maybe to call it RenamedFrom: or something like this? It would be very helpfull for us since we would like to know what file was deleted that way. Thanks

act support please

I want to use this action with nektos/act.
https://github.com/nektos/act

But when I use act, An error occurred like this.

[FTP/deploy] โญ  Run Get Changed Files
[FTP/deploy]   โ˜  git clone 'https://github.com/jitterbit/get-changed-files' # ref=v1
[FTP/deploy]   ๐Ÿณ  docker cp src=/home/neo/.cache/act/jitterbit-get-changed-files@v1 dst=/actions/
[FTP/deploy]   ๐Ÿ’ฌ  ::debug::Payload keys: 
| Base commit: undefined
| Head commit: undefined
[FTP/deploy]   โ—  ::error::The base and head commits are missing from the payload for this push event. Please submit an issue on this action's GitHub repo.
[FTP/deploy]   โ—  ::error::Not Found
[FTP/deploy]   โŒ  Failure - Get Changed Files
Error: exit with `FAILURE`: 1

Could you fix this problem?

Head vs base ahead error

https://github.com/jitterbit/get-changed-files/blob/master/src/main.ts#L79

The base branch that github reports can be anywhere between the initial commit on the base branch where head branched off to the latest commit on the base branch (or any commit in between). This seems to happen most frequently when new commits are pushed after a PR is already open. This is fine for repos that require a rebase or merge on the base branch before merging a PR, but otherwise the line above occasionally throws an error. If this line were changed to core.info instead of core.setFailed all changed files are reported correctly so it's probably unnecessary to consider this failed when that check doesn't pass.

Head commit is not ahead of the base commit

Getting the following error for some of my CI's:
The head commit for this push event is not ahead of the base commit. Please submit an issue on this action's GitHub repo.
It is getting a base commit sha which I cannot find in the git log (presumably not there at all).
This behavior is not consistent, so I couldn't give you more info.

It does still correctly identify what files were changed since the last commit.

Seems like this repo is ABANDONED, alternatives suggestion

So the last change has been made back to 2020! And new GitHub Actions release will deprecate some critical functionality.
So as a warning to anyone using this plugin - you should consider alternatives.

The original one I was able to find is:
https://github.com/marketplace/actions/changed-files
It has over 800+ stars and seems very popular and still has updates released quite often (3 days ago at the date this issue was created).
Any other alternatives are welcome.

Error: The head commit for this pull_request event is not ahead of the base commit

Error output in GitHub action pushed me to create this issue:
image

./.github/workflows/check-codestyle.yml

name: Check codestyle

on:
  pull_request:
    types:
      - opened
      - synchronize

jobs:
  php-cs-fixer:
    runs-on: ubuntu-latest

    steps:
      - uses: actions/checkout@v2
        with:
          ref: 'refs/pull/${{ github.event.number }}/head'

      - id: files
        uses: jitterbit/get-changed-files@v1
        with:
          format: 'csv'

      - name: lint
        run: |
          FILES_COUNT=0
          CHANGED_FILES=""
          mapfile -d ',' -t added_modified_files < <(printf '%s,' '${{ steps.files.outputs.added_modified }}')
          for added_modified_file in "${added_modified_files[@]}"; do
            echo "Do something with this ${added_modified_file}."
            CHANGED_FILES=$(printf "%s\n${added_modified_file}" "$CHANGED_FILES")
            FILES_COUNT+=1
          done

          set -x
          // truncated due to nda

Error: "Not Found" when pushing a new branch

When i branch off from master, edit something and push the commit with the branch to remote, the action fails with:

Run jitterbit/get-changed-files@v1
Base commit: 0000000000000000000000000000000000000000
Head commit: 2c782e73f6c1676f7ae88c551f5a80f61216a68c
##[error]Not Found

However if i then push something on that branch afterwards, it works.

Tbf, it might just be me, not understanding exactly how github and branching works, but would love some guidance on whether or not i can get it to run on the very first push.

Bypass API rate limiting

Is there an option or a way to bypass GitHub's API rate limiting? Currently, when there are subsequent commits in a PR, this action fails due to API rate limiting and exits with message "API rate limit reached with installation ID ####".

Action only returns the first 300 changed files

I'm only seeing the first 300 files returned when I run this action. Even though there should be more files diffed between the commits. I don't think the action is currently going through the paginated results and pulling later pages. When we merge our staging branch into our release branch, sometimes we have over 300 files that were modified over the course of a week. Having the truncated changed files list keeps us from being able to execute all of the actions we want.

`set-output` command will be deprecated soon and upgrade to Node16.

Describe the bug
Recently we started seeing these warnings on github actions -

Warning: The `set-output` command is deprecated and will be disabled soon. Please upgrade to using Environment Files. For more information see: https://github.blog/changelog/2022-10-11-github-actions-deprecating-save-state-and-set-output-commands/

Warning: Node.js 12 actions are deprecated. For more information see: https://github.blog/changelog/2022-09-22-github-actions-all-actions-will-begin-running-on-node16-instead-of-node12/. Please update the following actions to use Node.js 16: jitterbit/get-changed-files

Looks like the action is internally using set-output command which will be disabled soon by github.

To Reproduce
Steps to reproduce the behavior:

  1. Run a workflow using jitterbit/get-changed-files.

Expected behavior
Warning should not be seen.

Additional context
This action is really important for us and it is being used in an important workflow.

Support for renamed and modified

Hi! I'm loving using your action, and just ran into a case where I had a file renamed and modified. I'm currently using the added_modified output, and I was puzzled that it didn't show up in that set. If the name added_modified indicates added OR modified, I'm wondering why the renamed file does not appear there? I don't think it means added and modified because it definitely triggers for files that are existing and just changed.

While I would expect all renamed files to be under renamed, this set alone doesn't give me enough information to tell me if a file is renamed and modified. For the subset of renamed files that are modified, I would think they would appear in added_modified? I'm not sure if this is a bug but please let me know if there is another way to get that list!

Action fails to run when amending previous commit

When amending a previous commit on a PR, get-changed-files@v1 failed with this error message:

Error: The head commit for this pull_request event is not ahead of the base commit. Please submit an issue on this action's GitHub repo.

Screen Shot 2022-10-13 at 16 58 06

Push action failed with empty list during Github actions outage

During the Github actions outage this morning - we were seeing push type action with a base commit that was loaded incorrectly as a null commit - formatted as a string of zero's rather than null or the empty string.

Base commit: 0000000000000000000000000000000000000000

Info level logs:

...
2022-03-16T19:42:47.8550564Z ##[group]Run jitterbit/get-changed-files@v1
2022-03-16T19:42:47.8550984Z with:
2022-03-16T19:42:47.8551518Z   token: ***
2022-03-16T19:42:47.8551883Z   format: space-delimited
2022-03-16T19:42:47.8552240Z env:
2022-03-16T19:42:47.8552845Z   TERM: xterm
2022-03-16T19:42:47.8553209Z   AWS_REGION: us-east-1
2022-03-16T19:42:47.8553576Z   name: DEST::/home/runner/bin
2022-03-16T19:42:47.8553941Z   PR_NUMBER: 5117
2022-03-16T19:42:47.8554324Z   BASE_REF: <REDACTED>
2022-03-16T19:42:47.8554738Z ##[endgroup]
2022-03-16T19:42:47.9280476Z Base commit: 0000000000000000000000000000000000000000
2022-03-16T19:42:47.9281842Z Head commit: <REDACTED>
...

This caused the changed files to be returned as empty, and the lookup to have succeeded.

Expected error

The base and head commits are missing from the payload for this push event. Please submit an issue on this action's GitHub repo.

Expected Mitigation

No needed mitigation, as Github service returned the issue went away.

Doesn't work for a push of many commits

When I push many commits, it just detect the changes from the last commit:

name: Test

on: push

jobs:
  test:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/[email protected]
      - uses: jitterbit/get-changed-files@v1
        id: abc
        with:
          format: space-delimited
          token: ${{ secrets.GITHUB_TOKEN }}
      - name: Printing
        run: |
          echo "All:"
          echo "${{ steps.abc.outputs.all }}"
          echo "Added:"
          echo "${{ steps.abc.outputs.added }}"
          echo "Removed:"
          echo "${{ steps.abc.outputs.removed }}"
          echo "Renamed:"
          echo "${{ steps.abc.outputs.renamed }}"
          echo "Modified:"
          echo "${{ steps.abc.outputs.modified }}"
          echo "Added+Modified:"
          echo "${{ steps.abc.outputs.added_modified }}"

Example from stackoverflow (not mine)

Use with `workflow_dispatch`

When manually running an Action, I get this error, which makes sense:

Error: This action only supports pull requests and pushes, workflow_dispatch events are not supported.

However this even happens if I add

if: github.event_name != 'workflow_dispatch'

I don't know if that's expected, but I'd very much like a way around it.

(Use case: run a workflow if particular files change, or if manually requested)

Get changes from master branch on each commit

I'm pretty beginner on github actions, but so far this action is very useful, thank you!

What I'm facing is the following situation:

  • open a PR with commit n1, with some condition on changed files that triggers some important job j1 to fail
  • commit again (n2) changing other files that does not trigger job #1, making checks to pass
  • the PR so far is passing on checks with both commits, but should not be merged since commit #1 did not make job j1 pass.

I've seen that the base commit used is the previous, so new commits on PR are compared just against previous one, not master branch. Is there a way to compare master and all PR's commit on each new change to avoid this?

[error]One of your files includes a space.

##[error]One of your files includes a space. Consider using a different output format or removing spaces from your filenames. Please submit an issue on this action's GitHub repo.

When a filename contains a space, the setup fails.

Force pushes use the incorrect base commit SHA

When force pushing a branch, the identified base commit is the old commit, rather than the shared parent commit.

For example in the commit graph below, A is the parent commit, B is the old commit, and C is the new, force-pushed commit after reverting B. When the force-push is performed, this action is using B as the base commit when it should be using A.

A
| \
B  C

Merge from the master branch flags all files as modified

This might be a noob question but I need some inputs if possible ? I am using the action to identify all the files that have been changed during a feature branch changes. And I run some checks intended on only the files changed in the feature branch to make sure they don't violate a rule. But when I merge master all the changes from the merge as also detected as modified files that ruins the rule setup.

Any idea on how to work around this issue ? Can we restrict the changes to be just from the feature branch even when a master is merged during the development ?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.