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

Add support for using github's glob pattern syntax #304

Merged
merged 61 commits into from
Jan 5, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
61 commits
Select commit Hold shift + click to select a range
ecc724c
Add support for using github's glob pattern syntax
jackton1 Jan 3, 2022
a231a93
Update sourcefiles.sh
jackton1 Jan 3, 2022
4b912e9
Update sourcefiles.sh
jackton1 Jan 3, 2022
dbafa2f
Update sourcefiles.sh
jackton1 Jan 3, 2022
f8cca33
Update sourcefiles.sh
jackton1 Jan 3, 2022
2a28854
Update sourcefiles.sh
jackton1 Jan 3, 2022
2ba4c86
Update sourcefiles.sh
jackton1 Jan 3, 2022
c6f82ab
Update sourcefiles.sh
jackton1 Jan 3, 2022
52b75e9
Update sourcefiles.sh
jackton1 Jan 3, 2022
be07875
Update sourcefiles.sh
jackton1 Jan 3, 2022
416132b
Update sourcefiles.sh
jackton1 Jan 3, 2022
604f7cc
Update action.yml
jackton1 Jan 3, 2022
991884a
Update action.yml
jackton1 Jan 3, 2022
fb80aec
Update action.yml
jackton1 Jan 3, 2022
24cb506
Update action.yml
jackton1 Jan 3, 2022
25c130c
Update sourcefiles.sh
jackton1 Jan 3, 2022
81e3a5e
Update sourcefiles.sh
jackton1 Jan 3, 2022
05bebcb
Update sourcefiles.sh
jackton1 Jan 3, 2022
c985ac1
Update sourcefiles.sh
jackton1 Jan 3, 2022
bea7851
Merge branch 'main' into feature/add-support-for-using-githubs-glob-p…
jackton1 Jan 3, 2022
349154c
Update sourcefiles.sh
jackton1 Jan 3, 2022
b40354f
Update sourcefiles.sh
jackton1 Jan 3, 2022
3672899
Update sourcefiles.sh
jackton1 Jan 3, 2022
92cbdf8
Update sourcefiles.sh
jackton1 Jan 3, 2022
fc5d12c
Update sourcefiles.sh
jackton1 Jan 3, 2022
db9455d
Update sourcefiles.sh
jackton1 Jan 3, 2022
598078e
Update sourcefiles.sh
jackton1 Jan 3, 2022
a8f5886
Update sourcefiles.sh
jackton1 Jan 3, 2022
638d123
Update sourcefiles.sh
jackton1 Jan 3, 2022
f602069
Update sourcefiles.sh
jackton1 Jan 3, 2022
26e40b2
Update sourcefiles.sh
jackton1 Jan 3, 2022
41411be
Update sourcefiles.sh
jackton1 Jan 3, 2022
a479a9d
Update sourcefiles.sh
jackton1 Jan 3, 2022
de409db
Update sourcefiles.sh
jackton1 Jan 3, 2022
f445276
Update sourcefiles.sh
jackton1 Jan 4, 2022
028c947
Update sourcefiles.sh
jackton1 Jan 4, 2022
2a3a080
Update sourcefiles.sh
jackton1 Jan 4, 2022
b816146
Update sourcefiles.sh
jackton1 Jan 4, 2022
3c868ae
Update sourcefiles.sh
jackton1 Jan 4, 2022
9c04d03
Update sourcefiles.sh
jackton1 Jan 4, 2022
79deab0
Update sourcefiles.sh
jackton1 Jan 4, 2022
37ace47
Update sourcefiles.sh
jackton1 Jan 4, 2022
f7b27aa
Update sourcefiles.sh
jackton1 Jan 4, 2022
be3560b
Update sourcefiles.sh
jackton1 Jan 4, 2022
6935203
Update sourcefiles.sh
jackton1 Jan 4, 2022
d32dc71
Update sourcefiles.sh
jackton1 Jan 4, 2022
1e088de
Update sourcefiles.sh
jackton1 Jan 4, 2022
4633ecc
Update sourcefiles.sh
jackton1 Jan 4, 2022
c392336
Update action.yml
jackton1 Jan 4, 2022
9a89b39
Update test.yml
jackton1 Jan 4, 2022
e388b93
Update changed-files-list.txt
jackton1 Jan 4, 2022
72138d2
Update changed-files-list.txt
jackton1 Jan 4, 2022
2697233
Update action.yml
jackton1 Jan 4, 2022
8444e89
Update action.yml
jackton1 Jan 5, 2022
58b9638
Merge branch 'main' into feature/add-support-for-using-githubs-glob-p…
jackton1 Jan 5, 2022
4ad795d
Update entrypoint.sh
jackton1 Jan 5, 2022
7f73aac
Update test.yml
jackton1 Jan 5, 2022
38c40fa
Update README.md
jackton1 Jan 5, 2022
e69e619
Update test.yml
jackton1 Jan 5, 2022
70378e0
Update entrypoint.sh
jackton1 Jan 5, 2022
bdbe756
Update test.yml
jackton1 Jan 5, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -342,7 +342,7 @@ jobs:
uses: ./
with:
files: |
.github/workflows/test.yml
**/test.yml
action.yml
separator: "|"
- name: Show output
Expand Down Expand Up @@ -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: |
(
Expand Down Expand Up @@ -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: |
Expand Down
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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"
Expand Down
8 changes: 7 additions & 1 deletion action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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 }}

Expand Down
14 changes: 9 additions & 5 deletions sourcefiles.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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[*]}"

Expand Down
1 change: 1 addition & 0 deletions test/changed-files-list.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@
action.yml
action.yml
action.yml
!*.txt