Skip to content

Commit

Permalink
added support for multiple globs
Browse files Browse the repository at this point in the history
  • Loading branch information
jsmith committed Sep 12, 2020
1 parent f850dc5 commit f04f25a
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 7 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
4 changes: 2 additions & 2 deletions __tests__/main.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)
})
7 changes: 4 additions & 3 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export function initClient<T extends {githubToken: string}>(

interface Inputs {
githubToken: string
glob: string
glob: string[]
tag: string
repo: string
owner: string
Expand Down Expand Up @@ -56,7 +56,7 @@ function getInputs(): Result<Inputs, RuntimeError> {
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
Expand Down Expand Up @@ -245,7 +245,8 @@ async function run(): Promise<void> {
.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
})
Expand Down

0 comments on commit f04f25a

Please sign in to comment.