mirror of
https://github.com/tj-actions/changed-files
synced 2025-01-29 03:34:50 +00:00
Add support for using github's glob pattern syntax (#304)
* Add support for using github's glob pattern syntax Fixes: #264 #265 * Update sourcefiles.sh * Update sourcefiles.sh * Update sourcefiles.sh * Update sourcefiles.sh * Update sourcefiles.sh * Update sourcefiles.sh * Update sourcefiles.sh * Update sourcefiles.sh Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> * Update sourcefiles.sh * Update sourcefiles.sh * Update action.yml * Update action.yml * Update action.yml * Update action.yml * Update sourcefiles.sh * Update sourcefiles.sh * Update sourcefiles.sh * Update sourcefiles.sh * Update sourcefiles.sh * Update sourcefiles.sh * Update sourcefiles.sh * Update sourcefiles.sh * Update sourcefiles.sh * Update sourcefiles.sh * Update sourcefiles.sh * Update sourcefiles.sh * Update sourcefiles.sh * Update sourcefiles.sh * Update sourcefiles.sh * Update sourcefiles.sh * Update sourcefiles.sh * Update sourcefiles.sh * Update sourcefiles.sh * Update sourcefiles.sh * Update sourcefiles.sh * Update sourcefiles.sh * Update sourcefiles.sh * Update sourcefiles.sh * Update sourcefiles.sh * Update sourcefiles.sh * Update sourcefiles.sh * Update sourcefiles.sh * Update sourcefiles.sh * Update sourcefiles.sh * Update sourcefiles.sh * Update sourcefiles.sh * Update action.yml * Update test.yml * Update changed-files-list.txt * Update changed-files-list.txt * Update action.yml * Update action.yml * Update entrypoint.sh * Update test.yml * Update README.md * Update test.yml * Update entrypoint.sh * Update test.yml Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
This commit is contained in:
parent
9b119a28a5
commit
4e8540cc23
5 changed files with 25 additions and 14 deletions
6
.github/workflows/test.yml
vendored
6
.github/workflows/test.yml
vendored
|
@ -342,7 +342,7 @@ jobs:
|
|||
uses: ./
|
||||
with:
|
||||
files: |
|
||||
.github/workflows/test.yml
|
||||
**/test.yml
|
||||
action.yml
|
||||
separator: "|"
|
||||
- name: Show output
|
||||
|
@ -425,7 +425,7 @@ jobs:
|
|||
test/changed-files-list.txt
|
||||
test/changed-files-list.txt
|
||||
files: |
|
||||
.github/workflows/rebase.yml
|
||||
**/workflows/rebase.yml
|
||||
- name: Verify any_changed from source files
|
||||
if: |
|
||||
(
|
||||
|
@ -555,7 +555,7 @@ jobs:
|
|||
uses: ./
|
||||
with:
|
||||
files: |
|
||||
.github/workflows/test.yml
|
||||
.github/**/test.yml
|
||||
- name: Verify only_changed files
|
||||
if: steps.changed-files-specific-only-changed.outputs.other_changed_files != ''
|
||||
run: |
|
||||
|
|
10
README.md
10
README.md
|
@ -31,7 +31,7 @@ Retrieve all changed files relative to the default branch (`pull_request*` based
|
|||
* Between the last remote branch commit and the current HEAD.
|
||||
* Restrict change detection to a subset of files.
|
||||
* Report on files that have at least one change.
|
||||
* [Regex pattern](https://www.gnu.org/software/grep/manual/grep.html#Regular-Expressions) matching on a subset of files.
|
||||
* [Glob pattern](https://docs.github.com/en/actions/learn-github-actions/workflow-syntax-for-github-actions#filter-pattern-cheat-sheet) matching on a subset of files.
|
||||
|
||||
## Usage
|
||||
|
||||
|
@ -173,10 +173,10 @@ Support this project with a :star:
|
|||
test.txt
|
||||
new.txt
|
||||
test_directory
|
||||
\.sh$
|
||||
.(png|jpeg)$
|
||||
.(sql|py)$
|
||||
^(mynewfile|custom)
|
||||
*.sh
|
||||
*.png
|
||||
*.jpeg
|
||||
**/migrate-*.sql
|
||||
|
||||
- name: Run step if any of the listed files above change
|
||||
if: steps.changed-files-specific.outputs.any_changed == "true"
|
||||
|
|
|
@ -108,6 +108,12 @@ runs:
|
|||
# https://github.community/t/input-variable-name-is-not-available-in-composite-run-steps/127611
|
||||
INPUT_FILES: ${{ inputs.files }}
|
||||
INPUT_FILES_FROM_SOURCE_FILE: ${{ inputs.files_from_source_file }}
|
||||
- name: Glob match
|
||||
uses: tj-actions/glob@v2
|
||||
id: glob
|
||||
with:
|
||||
files: ${{ steps.source-input-files.outputs.files }}
|
||||
files-separator: " "
|
||||
- run: |
|
||||
# "Set base sha..."
|
||||
if [[ -n "${{ inputs.base_sha }}" ]]; then
|
||||
|
@ -134,7 +140,7 @@ runs:
|
|||
INPUT_SHA: ${{ inputs.sha }}
|
||||
INPUT_BASE_SHA: ${{ steps.base-sha.outputs.base_sha }}
|
||||
INPUT_TOKEN: ${{ inputs.token }}
|
||||
INPUT_FILES: ${{ steps.source-input-files.outputs.files }}
|
||||
INPUT_FILES: ${{ steps.glob.outputs.paths }}
|
||||
INPUT_SEPARATOR: ${{ inputs.separator }}
|
||||
INPUT_PATH: ${{ inputs.path }}
|
||||
|
||||
|
|
|
@ -4,22 +4,26 @@ set -e
|
|||
|
||||
echo "::group::changed-files-from-source-file"
|
||||
|
||||
IFS=" " read -r -a FILES <<< "$(echo "${INPUT_FILES[@]}" | sort -u | tr "\n" " ")"
|
||||
RAW_FILES=()
|
||||
|
||||
if [[ -n $INPUT_FILES_FROM_SOURCE_FILE ]]; then
|
||||
for file in $INPUT_FILES_FROM_SOURCE_FILE
|
||||
do
|
||||
while read -r fileName; do
|
||||
FILES+=("$fileName")
|
||||
RAW_FILES+=("$fileName")
|
||||
done <"$file"
|
||||
done
|
||||
fi
|
||||
|
||||
echo "Input Files: ${FILES[*]}"
|
||||
IFS=" " read -r -a CLEAN_FILES <<< "$(echo "${RAW_FILES[*]}" | tr "\r\n" "\n" | tr " " "\n" | sort -u | awk -v d=" " '{s=(NR==1?s:s d)$0}END{print s}')"
|
||||
|
||||
IFS=" " read -r -a ALL_UNIQUE_FILES <<< "$(echo "${FILES[@]}" | tr " " "\n" | sort -u | tr "\n" " ")"
|
||||
IFS=" " read -r -a CLEAN_INPUT_FILES <<< "$(echo "${INPUT_FILES}" | tr "\r\n" "\n" | tr " " "\n" | sort -u | awk -v d=" " '{s=(NR==1?s:s d)$0}END{print s}')"
|
||||
|
||||
echo "All Unique Input files: ${ALL_UNIQUE_FILES[*]}"
|
||||
FILES=("${CLEAN_FILES[@]}" "${CLEAN_INPUT_FILES[@]}")
|
||||
|
||||
IFS=" " read -r -a ALL_UNIQUE_FILES <<< "$(echo "${FILES[@]}" | tr "\r\n" "\n" | tr " " "\n" | sort -u | awk -v d=" " '{s=(NR==1?s:s d)$0}END{print s}')"
|
||||
|
||||
echo "Input files: ${ALL_UNIQUE_FILES[*]}"
|
||||
|
||||
echo "::set-output name=files::${ALL_UNIQUE_FILES[*]}"
|
||||
|
||||
|
|
|
@ -2,3 +2,4 @@
|
|||
action.yml
|
||||
action.yml
|
||||
action.yml
|
||||
!*.txt
|
||||
|
|
Loading…
Reference in a new issue