Skip to content

Commit

Permalink
feat: add changed output (#26)
Browse files Browse the repository at this point in the history
Add additional output if any changed files.

This new output will simplify to detect changes inside a GitHub workflow without other validation of the files_* output lists.
  • Loading branch information
fty4 authored Mar 21, 2023
1 parent 8a6aec7 commit ee7aa77
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
2 changes: 2 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ inputs:
required: false
description: "The encoding for the output values, either 'string' (default) or 'json'."
outputs:
changed:
description: "Indicates whether a file has changed (boolean)"
files_created:
description: "The names of the newly created files"
files_updated:
Expand Down
8 changes: 8 additions & 0 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,14 @@ async function run(): Promise<void> {

const encoder = getEncoder();

let hasChanged = false;
const totalModified =
changedFiles.created.length + changedFiles.updated.length + changedFiles.deleted.length;
if (totalModified > 0) {
hasChanged = true;
}

core.setOutput("changed", String(hasChanged));
core.setOutput("files_created", encoder(changedFiles.created));
core.setOutput("files_updated", encoder(changedFiles.updated));
core.setOutput("files_deleted", encoder(changedFiles.deleted));
Expand Down

0 comments on commit ee7aa77

Please sign in to comment.