A GitHub Action for matching glob patterns.
- Matches filenames and pathes using glob patterns
- ... in the file system
- ... from a user-supplied input
- ... from an input pipe
- Fast execution
- Scales to large repositories
- Supports all platforms (Linux, macOS, Windows)
- Does not use external GitHub Actions dependencies
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Glob Match
id: glob
uses: zyactions/glob@v2
with:
pattern: |
**/[ac].txt
!test/a.txt
- name: Print Matches
run: |
echo "${{ steps.glob.outputs.matches }}"steps:
- name: Glob Match
id: glob
uses: zyactions/glob@v2
with:
pattern: '**/[ac].txt'
values: |-
test/a.txt
test/b.txt
text/c.txt
- name: Print Matches
run: |
echo "${{ steps.glob.outputs.matches }}"The input values must be separated by line breaks.
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Glob Match
id: glob
uses: zyactions/glob@v2
with:
pattern: '**/[ac].txt'
pipe: 'git diff --name-only'
- name: Print Matches
run: |
echo "${{ steps.glob.outputs.matches }}"This is especially useful when a large number of items need to be matched without first storing them in an action output, environment variable, temporary file, or other temporary storage.
The input values returned by the pipe command must be separated by line breaks.
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Glob Match
id: glob
uses: zyactions/glob@v2
with:
pattern: '**/[ac].txt'
return-pipe: true
- name: Print Matches
shell: bash
run: |
${{ steps.glob.outputs.pipe }} | while IFS= read -r x ; do echo $x ; doneThe return-pipe option can also be combined with the pipe input to insert a glob filter step in the middle of a pipeline.
The working-directory for the action.
Defaults to the repository root directory (github.workspace).
When working on the file system, patterns and matches are considered relative to the specified working directory. If the pipe input is used, the pipe command will be executed in the current working-directory. This input has no effect if the values input is set.
The working directory will as well be included in the pipe output, if return-pipe is enabled.
One or more file, path, or placeholder patterns that describe which items to match.
Check out the glob pattern cheat sheet for reference. Multi line patterns must be specified without quotes.
Note
When running on Windows,
/and\are accepted as path separators. When running on UNIX systems, only/is accepted as the path separator. This as well applies to the input values.
An optional list of values to be matched (separated by line breaks).
The action operates on the file system if neither the values-, nor the pipe-input is set.
Note: This input must be used mutually exclusive with the
pipeinput.
An optional pipe input from which the input values are to be read.
This must be set to a valid shell command line (bash) that can be used for piping. The command must output to stdout and separate the individual values by line breaks.
The action operates on the file system if neither the values-, nor the pipe-input is set.
Warning
The command passed to this input will be evaluated and should not come from untrusted sources.
Note:
The pipe command is executed in the current
working-directoryby default. If the pipe command is to be executed in another working directory, make sure to properly insert a directory change command.Example pipe command:
(cd '/my/absolute/workdir' && ls -1)
Note: This input must be used mutually exclusive with the
valuesinput.
Enable this option to return a shell (bash) command in the pipe output that can be used for piping.
The output command must be evaled to return the results. It can also be passed to other actions that support a pipe input.
Note: The
matchesoutput will not be populated if this option is enabled.
A list of all matching elements, delimited by newlines or spaces (if the quote option is used).
Note: This output is only available if the
return-pipeoption is not enabled.
A shell (bash) command which can be used for piping.
Note: This output is only available if the
return-pipeoption is enabled.
This action does not use external GitHub Actions dependencies.
Internal depenencies:
- wcmatch (bundled)
Versions follow the semantic versioning scheme.
Glob Match Action is licensed under the MIT license.