From f04f25ac095fa1a02043eba529042e6a1a761598 Mon Sep 17 00:00:00 2001 From: Jacob Smith Date: Sat, 12 Sep 2020 19:31:24 -0300 Subject: [PATCH] added support for multiple globs --- README.md | 4 ++-- __tests__/main.test.ts | 4 ++-- src/main.ts | 7 ++++--- 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index b913ab1..b2f5abd 100644 --- a/README.md +++ b/README.md @@ -10,11 +10,11 @@ Do you do deployments when you push a new tag? Do you ever have multiple deploym ### glob -**description**: The glob of the files to check for changes (uses [`minimatch`](https://github.com/isaacs/minimatch)). All file changes that don't match this glob are filtered out. Defaults to "\*\*". +**description**: The glob(s) of the files to check for changes (uses [`minimatch`](https://github.com/isaacs/minimatch)). All file changes that don't match at least one of the globs are filtered out. If you want to provide multiple globs, use a `,` between each glob. Defaults to `**`. **required**: false **example**: `src/**` **example**: `**` -**example**: `*.js` +**example**: `*.js,*.py` ## Outputs diff --git a/__tests__/main.test.ts b/__tests__/main.test.ts index 7f09353..0e72fec 100644 --- a/__tests__/main.test.ts +++ b/__tests__/main.test.ts @@ -62,11 +62,11 @@ const runAndExpect = ( test('test runs', () => { runAndExpect('v0.1.0', {}, true) runAndExpect('v0.2.0', {added: ['src/b.txt']}, false) - runAndExpect('v0.2.0', {added: ['src/b.txt']}, false, 'src/**') + runAndExpect('v0.2.0', {added: ['src/b.txt']}, false, 'other/**,src/**') runAndExpect('v0.3.0', {modified: ['a.txt']}, false) runAndExpect('v0.3.0', {}, false, 'src/**') runAndExpect('v0.4.0', {removed: ['src/b.txt']}, false) runAndExpect('v0.4.0', {removed: ['src/b.txt']}, false, '**/*.txt') - runAndExpect('v0.4.0', {}, false, '*.py') + runAndExpect('v0.4.0', {}, false, '*.py,*.js') runAndExpect('v0.5.0', {renamed: ['b.txt']}, false) }) diff --git a/src/main.ts b/src/main.ts index 5342537..934f431 100644 --- a/src/main.ts +++ b/src/main.ts @@ -28,7 +28,7 @@ export function initClient( interface Inputs { githubToken: string - glob: string + glob: string[] tag: string repo: string owner: string @@ -56,7 +56,7 @@ function getInputs(): Result { tag = match[1] } - const glob = core.getInput('glob') || '**' + const glob = (core.getInput('glob') || '**').split(',') core.info(`Looking for changes in "${glob}"`) const repo = core.getInput('repo') || context.repo.repo @@ -245,7 +245,8 @@ async function run(): Promise { .andThen(getChangedFiles) .map(o => { o.changedFiles = o.changedFiles.filter(file => { - if (!minimatch(file.filename, o.glob)) return false + // If every glob doesn't match, filter out the file + if (o.glob.every(glob => !minimatch(file.filename, glob))) return false core.debug(`Matched "${file.filename}"`) return true })