Skip to content

Commit 11eb228

Browse files
committed
feat: adding any and all boolean outputs
This adds two boolean outputs `any` and `all` so that someone can track whether (1) any filter has at least one changed file, or (2) all filters have at least one changed file Closes #266 Signed-off-by: Scott Crooks <[email protected]>
1 parent de90cc6 commit 11eb228

File tree

3 files changed

+16
-0
lines changed

3 files changed

+16
-0
lines changed

action.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,10 @@ inputs:
4545
required: false
4646
default: '100'
4747
outputs:
48+
all:
49+
description: Boolean value indicating if all of the filters contained at least one changed file
50+
any:
51+
description: Boolean value indicating if any of the filters contained at least one changed file
4852
changes:
4953
description: JSON array with names of all filters matching any of changed files
5054
runs:

dist/index.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -745,25 +745,31 @@ async function getChangedFilesFromApi(token, pullRequest) {
745745
function exportResults(results, format) {
746746
core.info('Results:');
747747
const changes = [];
748+
let anyChanged = false;
749+
let allChanged = true;
748750
for (const [key, files] of Object.entries(results)) {
749751
const value = files.length > 0;
750752
core.startGroup(`Filter ${key} = ${value}`);
751753
if (files.length > 0) {
752754
changes.push(key);
755+
anyChanged = true;
753756
core.info('Matching files:');
754757
for (const file of files) {
755758
core.info(`${file.filename} [${file.status}]`);
756759
}
757760
}
758761
else {
759762
core.info('Matching files: none');
763+
allChanged = false;
760764
}
761765
core.setOutput(key, value);
762766
core.setOutput(`${key}_count`, files.length);
763767
if (format !== 'none') {
764768
const filesValue = serializeExport(files, format);
765769
core.setOutput(`${key}_files`, filesValue);
766770
}
771+
core.setOutput("all", allChanged);
772+
core.setOutput("any", anyChanged);
767773
core.endGroup();
768774
}
769775
if (results['changes'] === undefined) {

src/main.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -231,17 +231,21 @@ async function getChangedFilesFromApi(token: string, pullRequest: PullRequestEve
231231
function exportResults(results: FilterResults, format: ExportFormat): void {
232232
core.info('Results:')
233233
const changes = []
234+
let anyChanged = false
235+
let allChanged = true
234236
for (const [key, files] of Object.entries(results)) {
235237
const value = files.length > 0
236238
core.startGroup(`Filter ${key} = ${value}`)
237239
if (files.length > 0) {
238240
changes.push(key)
241+
anyChanged = true
239242
core.info('Matching files:')
240243
for (const file of files) {
241244
core.info(`${file.filename} [${file.status}]`)
242245
}
243246
} else {
244247
core.info('Matching files: none')
248+
allChanged = false
245249
}
246250

247251
core.setOutput(key, value)
@@ -250,6 +254,8 @@ function exportResults(results: FilterResults, format: ExportFormat): void {
250254
const filesValue = serializeExport(files, format)
251255
core.setOutput(`${key}_files`, filesValue)
252256
}
257+
core.setOutput('all', allChanged)
258+
core.setOutput('any', anyChanged)
253259
core.endGroup()
254260
}
255261

0 commit comments

Comments
 (0)