Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature] include/exclude filters (#1) #2

Merged
merged 14 commits into from
Jul 27, 2021
12 changes: 7 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ The `steps` output context exposes the output names `all`, `added`, `modified`,
See [action.yml](action.yml)

```yaml
- uses: Ana06/get-changed-files@v1.2
- uses: Ana06/get-changed-files@v2.0.0
with:
# Format of the steps output context.
# Can be 'space-delimited', 'csv', or 'json'.
Expand Down Expand Up @@ -47,7 +47,7 @@ Consider using one of the other formats if that's the case.

```yaml
- id: files
uses: Ana06/get-changed-files@v1.2
uses: Ana06/get-changed-files@v2.0.0
with:
glob-filter: '*.php'
- run: |
Expand All @@ -63,7 +63,7 @@ Therefore, including all YML files first and excluding the YML files of your `.g
If those two globs were inverted, you **would** include all the YML files, with the ones in your `.github/*/` directories.

```yaml
- uses: Ana06/get-changed-files@v1.2
- uses: Ana06/get-changed-files@v2.0.0
with:
# Format of the steps output context.
# Can be 'space-delimited', 'csv', or 'json'.
Expand All @@ -79,9 +79,10 @@ If those two globs were inverted, you **would** include all the YML files, with

```yaml
- id: files
uses: Ana06/get-changed-files@v1.2
uses: Ana06/get-changed-files@v2.0.0
with:
format: 'csv'
glob-filter: '*'
- run: |
mapfile -d ',' -t added_modified_files < <(printf '%s,' '${{ steps.files.outputs.added_modified }}')
for added_modified_file in "${added_modified_files[@]}"; do
Expand All @@ -93,9 +94,10 @@ If those two globs were inverted, you **would** include all the YML files, with

```yaml
- id: files
uses: Ana06/get-changed-files@v1.2
uses: Ana06/get-changed-files@v2.0.0
with:
format: 'json'
glob-filter: '*'
- run: |
readarray -t removed_files <<<"$(jq -r '.[]' <<<'${{ steps.files.outputs.removed }}')"
for removed_file in ${removed_files[@]}; do
Expand Down
2 changes: 1 addition & 1 deletion action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ inputs:
Can be 'space-delimited', 'csv', or 'json'.
required: true
default: space-delimited
filter:
glob-filter:
required: true
default: '*'
outputs:
Expand Down
1 change: 0 additions & 1 deletion dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4596,7 +4596,6 @@ function run() {
const all = [], added = [], modified = [], removed = [], renamed = [], addedModified = [];
for (const file of files) {
const filename = file.filename;
core.debug(`${filename}`);
// If we're using the 'space-delimited' format and any of the filenames have a space in them,
// then fail the step.
if (format === 'space-delimited' && filename.includes(' ')) {
Expand Down
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "get-changed-files",
"description": "GitHub action that gets all changed files in a pull request or push.",
"version": "1.0.0",
"version": "2.0.0",
"private": true,
"author": "Jitterbit, Inc.",
"license": "MIT",
Expand Down Expand Up @@ -45,18 +45,18 @@
"devDependencies": {
"@octokit/rest": "^16.40.2",
"@types/jest": "^25.1.1",
"@types/minimatch": "3.0.4",
"@types/node": "^14.17.0",
"@typescript-eslint/parser": "^2.8.0",
"@zeit/ncc": "^0.21.0",
"@types/minimatch": "3.0.4",
"eslint": "^6.8.0",
"eslint-plugin-github": "^3.4.0",
"eslint-plugin-jest": "^23.6.0",
"eslint-plugin-prettier": "^3.1.2",
"minimatch": "3.0.4",
"jest": "^25.1.0",
"jest-circus": "^25.1.0",
"js-yaml": "^3.13.1",
"minimatch": "3.0.4",
rnsc marked this conversation as resolved.
Show resolved Hide resolved
"prettier": "^1.19.1",
"rimraf": "^3.0.0",
"ts-jest": "^25.1.0",
Expand Down
1 change: 0 additions & 1 deletion src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,6 @@ async function run(): Promise<void> {
addedModified = [] as string[]
for (const file of files) {
const filename = file.filename
core.debug(`${filename}`)
// If we're using the 'space-delimited' format and any of the filenames have a space in them,
// then fail the step.
if (format === 'space-delimited' && filename.includes(' ')) {
Expand Down