Skip to content

[BUG] modified_keys and changed_key outputs not set when no changes detected #2456

@piotr-bzdyl-vertexinc

Description

@piotr-bzdyl-vertexinc

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?

According to the docs, modified_keys and changed_keys. However, when no changes are detected they are not set at all:

if (modifiedKeys.length > 0) {
await setArrayOutput({
key: 'modified_keys',
inputs,
value: modifiedKeys
})
}
if (changedKeys.length > 0) {
await setArrayOutput({
key: 'changed_keys',
inputs,
value: changedKeys
})
}
}

This requires custom handling of these outputs (checking for their presence etc.) Instead they should be always set, in case of no changes they would be just empty lists and they could be handled consistently like any other list.

To Reproduce

E.g. in a repository with some files (e.g. a.txt, b.txt and c.txt) run this action with the following setup:

name: Check changed files
uses: tj-actions/changed-files@e9772d140489982e0e3704fea5ee93d536f1e275  # v45.0.1
with:
  files_yaml: |
    a:
      - a.txt
    b:
      - b.txt
  json: true
  escape_json: false
  write_output_files: true
  output_dir: ${{ runner.temp }}/changed-files

And create a PR that changes only c.txt. As a result, the changed-files step won't create ${{ runner.temp }}/changed-files/modified_keys.json and ${{ runner.temp }}/changed-files/changed_keys.json files.

What OS are you seeing the problem on?

ubuntu-latest or ubuntu-22.04

Expected behavior?

changed_keys and modified_keys are always set, even though they would be empty lists.

Relevant log output

error: Could not open file /runner/_work/_temp/changed-files/modified_keys.json: No such file or directory

Has all relevant logs been included?

  • I've included all relevant logs

Anything else?

No response

Code of Conduct

  • I agree to follow this project's Code of Conduct

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions