Skip to content

feat: adding any and all boolean outputs #267

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,10 @@ inputs:
required: false
default: '100'
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:
Expand Down
6 changes: 6 additions & 0 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -745,25 +745,31 @@ 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}]`);
}
}
else {
core.info('Matching files: none');
allChanged = false;
}
core.setOutput(key, value);
core.setOutput(`${key}_count`, files.length);
if (format !== 'none') {
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) {
Expand Down
6 changes: 6 additions & 0 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -231,17 +231,21 @@ async function getChangedFilesFromApi(token: string, pullRequest: PullRequestEve
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)
Expand All @@ -250,6 +254,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()
}

Expand Down