trilom / file-changes-action

This action can be added, and you will get outputs of all of the files that have changed in your repository for you to use.
MIT License
167 stars 48 forks source link

Files rename error #93

Closed baeyun closed 4 years ago

baeyun commented 4 years ago

The following error appears when files are renamed:

(node:3580) UnhandledPromiseRejectionWarning: Error: {"error":"500/TypeError","from":"sortChangedFiles","message":"There was an issue sorting files changed.","payload":"{}"}
    at run (/home/runner/work/_actions/trilom/file-changes-action/v1.2.3/dist/index.js:1:19989)
    at processTicksAndRejections (internal/process/task_queues.js:93:5)
(node:3580) 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:3580) [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.
##[error]There was an issue sorting changed files from Github.
Exception: {
  "error": "500/TypeError",
  "from": "sortChangedFiles",
  "message": "There was an issue sorting files changed.",
  "payload": "{}"
}

Setup looks like this:

steps:
  - id: file_changes
    uses: trilom/file-changes-action@v1.2.3
    with:
      output: 'json' # optional output format
  - name: Checkout
    uses: actions/checkout@v2
  - name: Dummy Action
    uses: ./ # Uses an action in the root directory
    id: dummy_action
    with:
      authToken: ${{ secrets.GITHUB_TOKEN }}
      files_added: ${{ steps.file_changes.outputs.files_added }}
      files_modified: ${{ steps.file_changes.outputs.files_modified }}
      files_removed: ${{ steps.file_changes.outputs.files_removed }}

Is there a recommended way to get renamed files? (BTW, cool action)

trilom commented 4 years ago

Hey there, thanks for the input!

Could you set the secret on the repo ACTIONS_STEP_DEBUG to true and there should be an output: Here are the files I am changing: ...

Can you grab this so we can see what it looks like? From what I can see it should contain an array of changed files. It might either be empty, or contain some unexpected inputs/issues.

One thing I think MIGHT cause the issue is the fact that you're not pulling the repo prior to using the action, I believe it should work without pulling the repo AFAIK but I am not 💯

baeyun commented 4 years ago

Here are the outputs with the ACTIONS_STEP_DEBUG secret set to true:

##[debug]Here are the files I am changing: [
##[debug]  {
##[debug]    "sha": "cd183c8c3a39afb73373ff04354e2fc7505d486e",
##[debug]    "filename": "posts/post-01 copy 60.md",
##[debug]    "status": "renamed",
##[debug]    "additions": 0,
##[debug]    "deletions": 0,
##[debug]    "changes": 0,
##[debug]    "blob_url": "https://github.com/bukharim96/blogg-template/blob/ff29474d83a87ea102a3433c4c5cbd6dfb836f0c/posts/post-01%20copy%2060.md",
##[debug]    "raw_url": "https://github.com/bukharim96/blogg-template/raw/ff29474d83a87ea102a3433c4c5cbd6dfb836f0c/posts/post-01%20copy%2060.md",
##[debug]    "contents_url": "https://api.github.com/repos/bukharim96/blogg-template/contents/posts/post-01%20copy%2060.md?ref=ff29474d83a87ea102a3433c4c5cbd6dfb836f0c",
##[debug]    "previous_filename": "posts/post-01 copy 67.md"
##[debug]  }
##[debug]]
##[error]There was an issue sorting changed files from Github.
Exception: {
  "error": "500/TypeError",
  "from": "sortChangedFiles",
  "message": "There was an issue sorting files changed.",
  "payload": "{}"
}
(node:2485) UnhandledPromiseRejectionWarning: Error: {"error":"500/TypeError","from":"sortChangedFiles","message":"There was an issue sorting files changed.","payload":"{}"}
    at run (/home/runner/work/_actions/trilom/file-changes-action/v1.2.3/dist/index.js:1:19989)
    at processTicksAndRejections (internal/process/task_queues.js:93:5)
(node:2485) 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:2485) [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.
##[debug]Node Action run completed with exit code 1
##[debug]Finishing: Run trilom/file-changes-action@v1.2.3

The action fails on file rename. BTW, I'm pushing the changes not pulling them.

trilom commented 4 years ago

I see the issue- thanks for the feedback, I’ll tag this issue when it’s resolved.

kaineer commented 4 years ago

Looks like exception is thrown here: https://github.com/trilom/file-changes-action/blob/a6ac0c3c43b7f68b8bde51c901439c367a7f280f/src/FilesHelper.ts#L24, when there's an attempt to modify changedFiles.renamed (which isn't present now).

I've searched github api and here: https://developer.github.com/v3/repos/commits/#compare-two-commits I've found this: «This includes the status of the change (for example, if a file was added, removed, modified, or renamed)».

Usually I do not use ts, but I'll try to make a PR tomorrow (because my organization need it badly :)

P.S. Anyway, I can merge it in fork and use action from there.

trilom commented 4 years ago

This is being merged in #99

trilom commented 4 years ago

Thank you everyone for doing my work for me.

I love explaining to my 9 year old how I make a thing for me, and I put it out there in the world and people go "great! It's 90% of what I need and I just need to fix/add this one little thing.".

baeyun commented 4 years ago

Nice! OSS is just great.