mirror of
https://github.com/tj-actions/changed-files
synced 2024-12-17 03:47:20 +00:00
feat: add support for excluding the top level directory (#967)
This commit is contained in:
parent
dddfbd694c
commit
08f351ba16
3 changed files with 31 additions and 0 deletions
22
.github/workflows/test.yml
vendored
22
.github/workflows/test.yml
vendored
|
@ -446,6 +446,28 @@ jobs:
|
||||||
exit 1
|
exit 1
|
||||||
shell:
|
shell:
|
||||||
bash
|
bash
|
||||||
|
- name: Run changed-files with dir_names and dir_names_exclude_root
|
||||||
|
id: changed-files-dir-names-exclude-root
|
||||||
|
uses: ./
|
||||||
|
with:
|
||||||
|
base_sha: dddfbd69
|
||||||
|
sha: ce8c1983
|
||||||
|
fetch_depth: 60000
|
||||||
|
dir_names: "true"
|
||||||
|
dir_names_exclude_root: "true"
|
||||||
|
dir_names_max_depth: "1"
|
||||||
|
- name: Show output
|
||||||
|
run: |
|
||||||
|
echo '${{ toJSON(steps.changed-files-dir-names-exclude-root.outputs) }}'
|
||||||
|
shell:
|
||||||
|
bash
|
||||||
|
- name: Check dir_names output
|
||||||
|
if: steps.changed-files-dir-names-exclude-root.outputs.all_changed_files != '.github'
|
||||||
|
run: |
|
||||||
|
echo "Invalid output: Expected (.github) got (${{ steps.changed-files-dir-names-exclude-root.outputs.all_changed_files }})"
|
||||||
|
exit 1
|
||||||
|
shell:
|
||||||
|
bash
|
||||||
- name: Run changed-files with dir_names
|
- name: Run changed-files with dir_names
|
||||||
id: changed-files-dir-names
|
id: changed-files-dir-names
|
||||||
uses: ./
|
uses: ./
|
||||||
|
|
|
@ -75,6 +75,10 @@ inputs:
|
||||||
dir_names_max_depth:
|
dir_names_max_depth:
|
||||||
description: "Maximum depth of directories to output. e.g `test/test1/test2` with max depth of `2` returns `test/test1`."
|
description: "Maximum depth of directories to output. e.g `test/test1/test2` with max depth of `2` returns `test/test1`."
|
||||||
required: false
|
required: false
|
||||||
|
dir_names_exclude_root:
|
||||||
|
description: "Exclude the root directory represented by `.` from the output when `dir_names`is set to `true`."
|
||||||
|
required: false
|
||||||
|
default: "false"
|
||||||
json:
|
json:
|
||||||
description: "Output list of changed files in a JSON formatted string which can be used for matrix jobs."
|
description: "Output list of changed files in a JSON formatted string which can be used for matrix jobs."
|
||||||
required: false
|
required: false
|
||||||
|
@ -245,6 +249,7 @@ runs:
|
||||||
INPUT_DIFF_RELATIVE: ${{ inputs.diff_relative }}
|
INPUT_DIFF_RELATIVE: ${{ inputs.diff_relative }}
|
||||||
INPUT_DIR_NAMES: ${{ inputs.dir_names }}
|
INPUT_DIR_NAMES: ${{ inputs.dir_names }}
|
||||||
INPUT_DIR_NAMES_MAX_DEPTH: ${{ inputs.dir_names_max_depth }}
|
INPUT_DIR_NAMES_MAX_DEPTH: ${{ inputs.dir_names_max_depth }}
|
||||||
|
INPUT_DIR_NAMES_EXCLUDE_ROOT: ${{ inputs.dir_names_exclude_root }}
|
||||||
INPUT_JSON: ${{ inputs.json }}
|
INPUT_JSON: ${{ inputs.json }}
|
||||||
INPUT_HAS_CUSTOM_PATTERNS: ${{ steps.glob.outputs.has-custom-patterns }}
|
INPUT_HAS_CUSTOM_PATTERNS: ${{ steps.glob.outputs.has-custom-patterns }}
|
||||||
INPUT_JSON_RAW_FORMAT: ${{ inputs.json_raw_format }}
|
INPUT_JSON_RAW_FORMAT: ${{ inputs.json_raw_format }}
|
||||||
|
|
|
@ -47,6 +47,10 @@ function get_dirname_max_depth() {
|
||||||
depth=$((depth + 1))
|
depth=$((depth + 1))
|
||||||
done
|
done
|
||||||
|
|
||||||
|
if [[ "$INPUT_DIR_NAMES_EXCLUDE_ROOT" == "true" && "$output" == "." ]]; then
|
||||||
|
continue
|
||||||
|
fi
|
||||||
|
|
||||||
echo "$output"
|
echo "$output"
|
||||||
done < <(uniq)
|
done < <(uniq)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue