diff --git a/action.yml b/action.yml index 914524f..2aa16eb 100644 --- a/action.yml +++ b/action.yml @@ -50,6 +50,10 @@ inputs: required: false default: 'some' outputs: + all_changed: + description: Boolean value indicating if all of the filters contained at least one changed file + any_changed: + description: Boolean value indicating if any of the filters contained at least one changed file changes: description: JSON array with names of all filters matching any of changed files runs: diff --git a/dist/index.js b/dist/index.js index 10c9fda..efbffee 100644 --- a/dist/index.js +++ b/dist/index.js @@ -796,11 +796,14 @@ async function getChangedFilesFromApi(token, pullRequest) { function exportResults(results, format) { core.info('Results:'); const changes = []; + let anyChanged = false; + let allChanged = true; for (const [key, files] of Object.entries(results)) { const value = files.length > 0; core.startGroup(`Filter ${key} = ${value}`); if (files.length > 0) { changes.push(key); + anyChanged = true; core.info('Matching files:'); for (const file of files) { core.info(`${file.filename} [${file.status}]`); @@ -808,6 +811,7 @@ function exportResults(results, format) { } else { core.info('Matching files: none'); + allChanged = false; } core.setOutput(key, value); core.setOutput(`${key}_count`, files.length); @@ -815,6 +819,8 @@ function exportResults(results, format) { const filesValue = serializeExport(files, format); core.setOutput(`${key}_files`, filesValue); } + core.setOutput('all_changed', allChanged); + core.setOutput('any_changed', anyChanged); core.endGroup(); } if (results['changes'] === undefined) { diff --git a/src/main.ts b/src/main.ts index 6d6859d..7dd5b07 100644 --- a/src/main.ts +++ b/src/main.ts @@ -257,17 +257,21 @@ async function getChangedFilesFromApi(token: string, pullRequest: PullRequest): function exportResults(results: FilterResults, format: ExportFormat): void { core.info('Results:') const changes = [] + let anyChanged = false + let allChanged = true for (const [key, files] of Object.entries(results)) { const value = files.length > 0 core.startGroup(`Filter ${key} = ${value}`) if (files.length > 0) { changes.push(key) + anyChanged = true core.info('Matching files:') for (const file of files) { core.info(`${file.filename} [${file.status}]`) } } else { core.info('Matching files: none') + allChanged = false } core.setOutput(key, value) @@ -276,6 +280,8 @@ function exportResults(results: FilterResults, format: ExportFormat): void { const filesValue = serializeExport(files, format) core.setOutput(`${key}_files`, filesValue) } + core.setOutput('all_changed', allChanged) + core.setOutput('any_changed', anyChanged) core.endGroup() }