diff --git a/README.md b/README.md index b2f5abd..23ef068 100644 --- a/README.md +++ b/README.md @@ -22,6 +22,11 @@ Ensure to set the step ID using the `id` attribute. See the [docs](https://docs. ### steps..outputs.added +**description**: The names of all of the added, modified, removed and renamed files (comma separated). +**example**: `a.txt, src/b.txt` + +### steps..outputs.added + **description**: The names of the newly created files (comma separated). **example**: `a.txt, src/b.txt` diff --git a/__tests__/main.test.ts b/__tests__/main.test.ts index 0e72fec..fa492aa 100644 --- a/__tests__/main.test.ts +++ b/__tests__/main.test.ts @@ -49,6 +49,10 @@ const runAndExpect = ( expected.push(`::set-output name=any_changed::${anyChanged}`) expected.push(`::set-output name=first_tag::${firstTag}`) + const allFiles: string[] = [] + for (const items of Object.values(changed)) allFiles.push(...(items ?? [])) + expected.push(`::set-output name=files::${allFiles.join(', ')}`) + for (const line of expected) { if (!output.match(new RegExp(escapeRegExp(line)))) { throw Error( diff --git a/src/main.ts b/src/main.ts index 934f431..d6f7004 100644 --- a/src/main.ts +++ b/src/main.ts @@ -245,8 +245,8 @@ async function run(): Promise { .andThen(getChangedFiles) .map(o => { o.changedFiles = o.changedFiles.filter(file => { - // If every glob doesn't match, filter out the file - if (o.glob.every(glob => !minimatch(file.filename, glob))) return false + // If there isn't at least one match, filter out the file + if (!o.glob.some(glob => minimatch(file.filename, glob))) return false core.debug(`Matched "${file.filename}"`) return true }) @@ -256,12 +256,15 @@ async function run(): Promise { .andThen(sortChangedFiles) .andThen(({sorted, previousTag}) => { let anyChanged = false + const allFiles: string[] = [] for (const status of filesTypes) { anyChanged = anyChanged || sorted[status].length !== 0 core.debug(`Writing output ${status} with files ${sorted[status]}`) core.setOutput(status, sorted[status].join(', ')) + allFiles.push(...sorted[status]) } + core.setOutput('files', allFiles.join(', ')) core.setOutput('any_changed', anyChanged) core.setOutput('first_tag', previousTag === undefined) return ok({})