diff --git a/.github/workflows/pull-request-verification.yml b/.github/workflows/pull-request-verification.yml index 8b52384..eae29d6 100644 --- a/.github/workflows/pull-request-verification.yml +++ b/.github/workflows/pull-request-verification.yml @@ -142,7 +142,7 @@ jobs: run: echo "$OUTPUT" - name: filter-test - if: steps.filter.outputs.local != 'true' + if: !steps.filter.outputs.local run: exit 1 - name: count-test @@ -150,9 +150,9 @@ jobs: run: exit 1 - name: added-test - if: steps.filter.outputs.local_added != 1 + if: ${{ !steps.filter.outputs.local_added }} run: exit 1 - name: modified-test - if: steps.filter.outputs.local_modified != 0 + if: ${{ steps.filter.outputs.local_modified }} run: exit 1 diff --git a/dist/index.mjs b/dist/index.mjs index 138515e..68e259d 100644 --- a/dist/index.mjs +++ b/dist/index.mjs @@ -29679,10 +29679,15 @@ function exportResults(results, format) { } else { core3.info("Matching files: none"); } - core3.setOutput(key, value); + if (value) { + core3.setOutput(key, value); + } core3.setOutput(`${key}_count`, files.length); for (const status of Object.values(ChangeStatus)) { - core3.setOutput(`${key}_${status.toLocaleLowerCase()}`, files.filter((x) => x.status === status).length); + const matches = files.some((x) => x.status === status); + if (matches) { + core3.setOutput(`${key}_${status.toLocaleLowerCase()}`, true); + } } if (format !== "none") { const filesValue = serializeExport(files, format); diff --git a/src/main.ts b/src/main.ts index ab7babc..4d37982 100644 --- a/src/main.ts +++ b/src/main.ts @@ -240,11 +240,21 @@ function exportResults(results: FilterResults, format: ExportFormat): void { core.info('Matching files: none') } - core.setOutput(key, value) + if (value) { + // GH converts all outputs to strings + // if we output false, it will be converted to 'false' which is truthy + // if we don't output false, it will be converted to undefined which is falsy + // let's not output false to allow loose equality checks + core.setOutput(key, value) + } + core.setOutput(`${key}_count`, files.length) for (const status of Object.values(ChangeStatus)) { - core.setOutput(`${key}_${status.toLocaleLowerCase()}`, files.filter(x => x.status === status).length) + const matches = files.some(x => x.status === status) + if (matches) { + core.setOutput(`${key}_${status.toLocaleLowerCase()}`, true) + } } if (format !== 'none') {