Giter Site home page Giter Site logo

gh-action-get-changed-files's Introduction

GitHub Action: Get Changed Files

Saves lists of changed files in the outputs object and on the filesystem for use by other actions.

Workflow Config Example

- uses: lots0logs/[email protected]
  with:
    token: ${{ secrets.GITHUB_TOKEN }}

Inputs

Outputs

All output values are a single JSON encoded array.

  • all: Added, deleted, renamed and modified files
  • added: Added files
  • deleted: Deleted files
  • renamed: Renamed files
  • modified: Modified files

JSON Files Created By This Action

  • ${HOME}/files.json
  • ${HOME}/files_modified.json
  • ${HOME}/files_added.json
  • ${HOME}/files_deleted.json
  • ${HOME}/files_renamed.json

gh-action-get-changed-files's People

Contributors

dependabot[bot] avatar fabasoad avatar lots0logs avatar raik0707 avatar robdodson 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

Watchers

 avatar  avatar

gh-action-get-changed-files's Issues

Accessing the number of changed/added files

Hi there, thanks for this action, it works really well in our automated workflows!

There is one thing I don't know how to achieve and was wondering if you already know a solution: Most of your workflows act on modified or added files, meaning that they don't actually need to run if there are none (wasting server time and energy with installing libraries for nothing). However, I haven't found a way to test the size of a JSON array to include it in an if: clause. There might be a way to count elements after using join(steps.modified.outputs.modified) but I didn't manage. By any chance, have you or anyone else already encountered this and found a solution?

Otherwise, would it be easy to add another set of properties such as modified_n, added_n etc. to get the numbers? You wouldn't believe how much that would be helpful and appreciated.

TypeError: Cannot read property 'filter' of undefined

Thanks for this action! I tried to use this in my repo and I encountered an error when the action ran:

/entrypoint.js:7
const commits     = payload.commits.filter(c => c.distinct);
                                    ^

TypeError: Cannot read property 'filter' of undefined
    at Object.<anonymous> (/entrypoint.js:7:37)
    at Module._compile (internal/modules/cjs/loader.js:956:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:973:10)
    at Module.load (internal/modules/cjs/loader.js:812:32)
    at Function.Module._load (internal/modules/cjs/loader.js:724:14)
    at Function.Module.runMain (internal/modules/cjs/loader.js:1025:10)
    at internal/main/run_main_module.js:17:11
##[error]Docker run failed with exit code 1

You can see the whole run here: https://github.com/windmilleng/tilt/pull/2569/checks?check_run_id=305430725

Error: Cannot find module '@actions/github'

Hey just tried this action out, and I am seeing the following error.

Seems the packages aren't being installed.

internal/modules/cjs/loader.js:800
    throw err;
    ^

Error: Cannot find module '@actions/github'
Require stack:
- /home/runner/work/_actions/lots0logs/gh-action-get-changed-files/2.0.0/main.js
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:797:15)
    at Function.Module._load (internal/modules/cjs/loader.js:690:27)
    at Module.require (internal/modules/cjs/loader.js:852:19)
    at require (internal/modules/cjs/helpers.js:74:18)
    at Object.<anonymous> (/home/runner/work/_actions/lots0logs/gh-action-get-changed-files/2.0.0/main.js:3:12)
    at Module._compile (internal/modules/cjs/loader.js:959:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:995:10)
    at Module.load (internal/modules/cjs/loader.js:815:32)
    at Function.Module._load (internal/modules/cjs/loader.js:727:14)
    at Function.Module.runMain (internal/modules/cjs/loader.js:1047:10) {
  code: 'MODULE_NOT_FOUND',
  requireStack: [
    '/home/runner/work/_actions/lots0logs/gh-action-get-changed-files/2.0.0/main.js'
  ]
}
##[error]Node run failed with exit code 1

Example is incorrect

The current example doesn't work for me, I get an authentication token error from Github. This example does not work for me:

- uses: lots0logs/[email protected]
  with:
    token: GITHUB_TOKEN

This example does:

- uses: lots0logs/[email protected]
  with:
    token: ${{ secrets.GITHUB_TOKEN }}

I got this information from this document:
https://docs.github.com/en/actions/configuring-and-managing-workflows/authenticating-with-the-github_token#example-passing-github_token-as-an-input

Thank you for this project! It is working great for me.

outputs.all does not include deleted files

I am seeing consistently that runs where I delete a file, that the deleted file is not included in the outputs.all.

Here's an example commit: LongLiveCHIEF/atsamd@ad1e876
and the associated run: https://github.com/LongLiveCHIEF/atsamd/runs/3792750091?check_suite_focus=true#step:5:33

In the line referenced, the input to the generateBuildMatrix is from outputs.all. Notice how in the commit above, i changed the action file, and deleted one of the src files, but the array in the function only contains the modified file.

HttpError: API rate limit exceeded, stacktrace does not cause action to exit non-gracefully

This action "fails" with the following output:

Run lots0logs/[email protected]
  with:
    token: ***
(node:301) UnhandledPromiseRejectionWarning: HttpError: API rate limit exceeded for installation ID 2506633.
    at /runner/_work/_actions/lots0logs/gh-action-get-changed-files/2.1.4/dist/index.js:7470:23
    at processTicksAndRejections (internal/process/task_queues.js:93:5)
    at async getCommits (/runner/_work/_actions/lots0logs/gh-action-get-changed-files/2.1.4/dist/index.js:337:14)
(node:301) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:301) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

This is probably due to my token running out of API requests. The issue is that this does not cause the job to fail.

I have subsequent actions that rely on these files to tell me if parts of my build needs to run. I would have expected this action to fail non-gracefully and kill the remainder of my build. Instead, my build continues as if no files changed, thus passing my status checks.

Support For Windows Runners

Currently when attempting to use on a Windows Runner the process.env.HOME is undefined.

Suggest checking for the OS and if Windows, set process.env.HOME equal to the HOMEDRIVE and HOMEPATH environment variables.

deleted files are not listed

In the step name list json file, files_added.json and files_modified.json correctly contains the file names. However, files_deleted.json always is an empty array.

YML file I use:

on:
  push:
    branches:
    - master
    paths:
    - 'folder/**'
 
    
jobs:
  job1:
    runs-on: ubuntu-latest
  
    
    steps:
     - uses: actions/checkout@v1 
     - name: Get changed files
       uses: lots0logs/[email protected]
       with:
         token: ${{ secrets.personal_access_token }}
     - name: list json file
       run: |
        cat ${HOME}/files.json
        cat ${HOME}/files_modified.json
        cat ${HOME}/files_added.json
        cat ${HOME}/files_deleted.json
        ```

HttpError: Empty value for parameter 'owner': undefined

I don't know what's wrong. Any ideas?

Run lots0logs/[email protected]
(node:2517) UnhandledPromiseRejectionWarning: HttpError: Empty value for parameter 'owner': undefined
    at /home/runner/work/_actions/lots0logs/gh-action-get-changed-files/2.0.6/dist/main.js:3721:15
    at Array.forEach (<anonymous>)
    at /home/runner/work/_actions/lots0logs/gh-action-get-changed-files/2.0.6/dist/main.js:3689:12
    at Array.forEach (<anonymous>)
    at validate (/home/runner/work/_actions/lots0logs/gh-action-get-changed-files/2.0.6/dist/main.js:3662:23)
(node:2517) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:2517) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

Deleted files are on files_deleted.json and not files.json

Based on the README, the file files.json should contains all touched files (AMDR)

In my example when I delete a file, it's listed in the file files_deleted.json and not files.json

      - name: Test deleted files
        run: |
          cat ${HOME}/files.json
          cat ${HOME}/files_modified.json
          cat ${HOME}/files_added.json
          cat ${HOME}/files_deleted.json
          cat ${HOME}/files_renamed.json

TypeError: Cannot read property 'filter' of undefined

Hey guys,

seems to be the same error as in #2, just a different file.

/home/runner/work/_actions/lots0logs/gh-action-get-changed-files/2.0.6/dist/main.js:3567
const commits = context.payload.commits.filter(c => c.distinct);
                                       ^

TypeError: Cannot read property 'filter' of undefined

Full runthrough with error (just trying your action out here ;P): https://github.com/python-telegram-bot/python-telegram-bot/pull/1786/checks?check_run_id=459027793#step:6:1

Your action is implemented here, should be correct.

Reuse output

Regarding the output:

${HOME}/files.json
${HOME}/files_modified.json
${HOME}/files_added.json
${HOME}/files_deleted.json
${HOME}/files_renamed.json

How can we access these files in a subsequent step?

We are too blind to see.

We did now this but this cant be the solution:

    steps:
      - uses: actions/checkout@v2
        with:
          fetch-depth: 0
      - uses: lots0logs/[email protected]
        with:
          token: ${{ secrets.GITHUB_TOKEN }}
      - run: mv ~/files.json .                                                                   <------
      - uses: REPO/actions/checkmarx-check@main
        if: ${{ always() }}
        with:
          touched-files-file: /github/workspace/files.json                     <------

But that is the biggest hack. How did you intent these lines?
We also tried using ~ but it also seems hacky.

Appreciate it.

Max 300 files reported changed

Only the first 300 filed are reported changed...
I changed 2000 files and committed but only the first 300 where reported...

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.