From 43245574e6ad9f421b037c092cee2fdc28bf2c5d Mon Sep 17 00:00:00 2001 From: Tonye Jack Date: Fri, 30 Apr 2021 12:04:23 -0400 Subject: [PATCH 01/29] [WIP] Add support to filter only specific files --- action.yml | 77 +++++++++++++++++++++++++++++++++++++++--------------- 1 file changed, 56 insertions(+), 21 deletions(-) diff --git a/action.yml b/action.yml index 8b18a3ba..27747ff6 100644 --- a/action.yml +++ b/action.yml @@ -6,6 +6,10 @@ inputs: description: 'Split character for array output' required: true default: " " + files: + description: 'Check for file changes for all files listed (Defaults to the entire repo)' + required: false + default: "" outputs: added_files: @@ -54,29 +58,60 @@ runs: HEAD_SHA=$(git rev-parse ${TARGET_BRANCH} || true) fi - echo "Getting diff..." - ADDED=$(git diff --diff-filter=A --name-only "$HEAD_SHA" | tr "\n" "${{ inputs.separator }}" | sed -E 's/(${{ inputs.separator }})$//') - COPIED=$(git diff --diff-filter=C --name-only "$HEAD_SHA" | tr "\n" "${{ inputs.separator }}" | sed -E 's/(${{ inputs.separator }})$//') - DELETED=$(git diff --diff-filter=D --name-only "$HEAD_SHA" | tr "\n" "${{ inputs.separator }}" | sed -E 's/(${{ inputs.separator }})$//') - MODIFIED=$(git diff --diff-filter=M --name-only "$HEAD_SHA" | tr "\n" "${{ inputs.separator }}" | sed -E 's/(${{ inputs.separator }})$//') - RENAMED=$(git diff --diff-filter=R --name-only "$HEAD_SHA" | tr "\n" "${{ inputs.separator }}" | sed -E 's/(${{ inputs.separator }})$//') - CHANGED=$(git diff --diff-filter=T --name-only "$HEAD_SHA" | tr "\n" "${{ inputs.separator }}" | sed -E 's/(${{ inputs.separator }})$//') - UNMERGED=$(git diff --diff-filter=U --name-only "$HEAD_SHA" | tr "\n" "${{ inputs.separator }}" | sed -E 's/(${{ inputs.separator }})$//') - UNKNOWN=$(git diff --diff-filter=X --name-only "$HEAD_SHA" | tr "\n" "${{ inputs.separator }}" | sed -E 's/(${{ inputs.separator }})$//') - ALL_CHANGED=$(git diff --diff-filter='*ACDMRTUX' --name-only "$HEAD_SHA" | tr "\n" "${{ inputs.separator }}" | sed -E 's/(${{ inputs.separator }})$//') - ALL_MODIFIED_FILES=$(git diff --diff-filter='ACM' --name-only "$HEAD_SHA" | tr "\n" "${{ inputs.separator }}" | sed -E 's/(${{ inputs.separator }})$//') + if [[ -z $INPUT_FILES ]]; then + echo "Getting diff..." + + ADDED=$(git diff --diff-filter=A --name-only "$HEAD_SHA" | tr "\n" "${{ inputs.separator }}" | sed -E 's/(${{ inputs.separator }})$//') + COPIED=$(git diff --diff-filter=C --name-only "$HEAD_SHA" | tr "\n" "${{ inputs.separator }}" | sed -E 's/(${{ inputs.separator }})$//') + DELETED=$(git diff --diff-filter=D --name-only "$HEAD_SHA" | tr "\n" "${{ inputs.separator }}" | sed -E 's/(${{ inputs.separator }})$//') + MODIFIED=$(git diff --diff-filter=M --name-only "$HEAD_SHA" | tr "\n" "${{ inputs.separator }}" | sed -E 's/(${{ inputs.separator }})$//') + RENAMED=$(git diff --diff-filter=R --name-only "$HEAD_SHA" | tr "\n" "${{ inputs.separator }}" | sed -E 's/(${{ inputs.separator }})$//') + CHANGED=$(git diff --diff-filter=T --name-only "$HEAD_SHA" | tr "\n" "${{ inputs.separator }}" | sed -E 's/(${{ inputs.separator }})$//') + UNMERGED=$(git diff --diff-filter=U --name-only "$HEAD_SHA" | tr "\n" "${{ inputs.separator }}" | sed -E 's/(${{ inputs.separator }})$//') + UNKNOWN=$(git diff --diff-filter=X --name-only "$HEAD_SHA" | tr "\n" "${{ inputs.separator }}" | sed -E 's/(${{ inputs.separator }})$//') + ALL_CHANGED=$(git diff --diff-filter='*ACDMRTUX' --name-only "$HEAD_SHA" | tr "\n" "${{ inputs.separator }}" | sed -E 's/(${{ inputs.separator }})$//') + ALL_MODIFIED_FILES=$(git diff --diff-filter='ACM' --name-only "$HEAD_SHA" | tr "\n" "${{ inputs.separator }}" | sed -E 's/(${{ inputs.separator }})$//') + + echo "::set-output name=added_files::$ADDED" + echo "::set-output name=copied_files::$COPIED" + echo "::set-output name=deleted_files::$DELETED" + echo "::set-output name=modified_files::$MODIFIED" + echo "::set-output name=renamed_files::$RENAMED" + echo "::set-output name=changed_files::$CHANGED" + echo "::set-output name=unmerged_files::$UNMERGED" + echo "::set-output name=unknown_files::$UNKNOWN" + echo "::set-output name=all_changed_files::$ALL_CHANGED" + echo "::set-output name=all_modified_files::$ALL_MODIFIED_FILES" + + else + ADDED_FILES=() + + for path in ${INPUT_FILES} + do + echo "Checking for file changes: \"${path}\"..." + MODIFIED_FILE=$(git diff --diff-filter=ACMUXTR --name-only | grep -E "(${path})" || true) + + if [[ -z $MODIFIED_FILE ]]; then + # Find unstaged changes + MODIFIED_FILE=$(git status --porcelain | awk '{ print $2 }' | grep -E "(${path})" || true) + fi + + if [[ -n ${MODIFIED_FILE} ]]; then + echo "Found uncommited changes at: ${path}" + CHANGED_FILES+=("${path}") + fi + done + + if [[ -z ${CHANGED_FILES} ]]; then + echo "::set-output name=files_changed::false" + else + echo "::set-output name=files_changed::true" + echo "::set-output name=changed_files::${CHANGED_FILES}" + fi + fi + - echo "::set-output name=added_files::$ADDED" - echo "::set-output name=copied_files::$COPIED" - echo "::set-output name=deleted_files::$DELETED" - echo "::set-output name=modified_files::$MODIFIED" - echo "::set-output name=renamed_files::$RENAMED" - echo "::set-output name=changed_files::$CHANGED" - echo "::set-output name=unmerged_files::$UNMERGED" - echo "::set-output name=unknown_files::$UNKNOWN" - echo "::set-output name=all_changed_files::$ALL_CHANGED" - echo "::set-output name=all_modified_files::$ALL_MODIFIED_FILES" shell: bash branding: From 085386c38bedf4e99c2b8c496864098adbedcb41 Mon Sep 17 00:00:00 2001 From: Tonye Jack Date: Sat, 1 May 2021 07:49:15 -0400 Subject: [PATCH 02/29] Update action.yml --- action.yml | 50 +++++++++++++++++++++++++++++++------------------- 1 file changed, 31 insertions(+), 19 deletions(-) diff --git a/action.yml b/action.yml index 27747ff6..f958de21 100644 --- a/action.yml +++ b/action.yml @@ -86,32 +86,44 @@ runs: else ADDED_FILES=() - + COPIED_FILES=() + DELETED_FILES=() + MODIFIED_FILES=() + RENAMED_FILES=() + CHANGED_FILES=() + UNMERGED_FILES=() + UNKNOWN_FILES=() + ALL_CHANGED=() + ALL_MODIFIED_FILES=() + for path in ${INPUT_FILES} do - echo "Checking for file changes: \"${path}\"..." - MODIFIED_FILE=$(git diff --diff-filter=ACMUXTR --name-only | grep -E "(${path})" || true) + echo "Checking for file changes: \"${path}\"..." - if [[ -z $MODIFIED_FILE ]]; then - # Find unstaged changes - MODIFIED_FILE=$(git status --porcelain | awk '{ print $2 }' | grep -E "(${path})" || true) - fi + ADDED_FILES+=$(git diff --diff-filter=A --name-only "$HEAD_SHA" | grep -E "(${path})") + COPIED_FILES+=$(git diff --diff-filter=C --name-only "$HEAD_SHA" | grep -E "(${path})") + DELETED_FILES+=$(git diff --diff-filter=D --name-only "$HEAD_SHA" | grep -E "(${path})") + MODIFIED_FILES+=$(git diff --diff-filter=M --name-only "$HEAD_SHA" | grep -E "(${path})") + RENAMED_FILES+=$(git diff --diff-filter=R --name-only "$HEAD_SHA" | grep -E "(${path})") + CHANGED_FILES+=$(git diff --diff-filter=T --name-only "$HEAD_SHA" | grep -E "(${path})") + UNMERGED_FILES+=$(git diff --diff-filter=U --name-only "$HEAD_SHA" | grep -E "(${path})") + UNKNOWN_FILES+=$(git diff --diff-filter=X --name-only "$HEAD_SHA" | grep -E "(${path})") + ALL_CHANGED+=$(git diff --diff-filter='*ACDMRTUX' --name-only "$HEAD_SHA" | grep -E "(${path})") + ALL_MODIFIED_FILES+=$(git diff --diff-filter='ACM' --name-only "$HEAD_SHA" | grep -E "(${path})") - if [[ -n ${MODIFIED_FILE} ]]; then - echo "Found uncommited changes at: ${path}" - CHANGED_FILES+=("${path}") - fi done - if [[ -z ${CHANGED_FILES} ]]; then - echo "::set-output name=files_changed::false" - else - echo "::set-output name=files_changed::true" - echo "::set-output name=changed_files::${CHANGED_FILES}" - fi + echo "::set-output name=added_files::$ADDED" + echo "::set-output name=copied_files::$COPIED" + echo "::set-output name=deleted_files::$DELETED" + echo "::set-output name=modified_files::$MODIFIED" + echo "::set-output name=renamed_files::$RENAMED" + echo "::set-output name=changed_files::$CHANGED" + echo "::set-output name=unmerged_files::$UNMERGED" + echo "::set-output name=unknown_files::$UNKNOWN" + echo "::set-output name=all_changed_files::$ALL_CHANGED" + echo "::set-output name=all_modified_files::$ALL_MODIFIED_FILES" fi - - shell: bash branding: From dc2959d455fdb20f8a59345aeb4203ea9a43477e Mon Sep 17 00:00:00 2001 From: Tonye Jack Date: Sat, 1 May 2021 07:55:01 -0400 Subject: [PATCH 03/29] Update test.yml --- .github/workflows/test.yml | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 25364eb4..613115ea 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -40,3 +40,13 @@ jobs: - name: Show output run: | echo "${{ toJSON(steps.changed-files-comma.outputs) }}" + - name: Run changed-files with specific files + id: changed-files-specific + uses: ./ + with: + files: | + action.yml + .github/workflows/test.yml + - name: Show output + run: | + echo "${{ toJSON(steps.changed-files-specific.outputs) }}" From ca0dcf8458096171c8cd2b73d14b5be48809158b Mon Sep 17 00:00:00 2001 From: Tonye Jack Date: Sat, 1 May 2021 07:57:27 -0400 Subject: [PATCH 04/29] Update README.md --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 887ddfd4..b029221c 100644 --- a/README.md +++ b/README.md @@ -41,6 +41,7 @@ Using the default separator. | Input | type | required | default | description | |:-------------:|:-----------:|:-------------:|:----------------------------:|:-------------:| | separator | `string` | `true` | `' '` | Separator to return outputs | +| files | `string|string[]` | `false` | | Restricted list of specific files to watch for changes | ## Usage From 6c57b1194109903c6b62e65b394f833172f03968 Mon Sep 17 00:00:00 2001 From: Tonye Jack Date: Sat, 1 May 2021 07:59:48 -0400 Subject: [PATCH 05/29] Update action.yml --- action.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/action.yml b/action.yml index f958de21..6c5d1a16 100644 --- a/action.yml +++ b/action.yml @@ -58,7 +58,7 @@ runs: HEAD_SHA=$(git rev-parse ${TARGET_BRANCH} || true) fi - if [[ -z $INPUT_FILES ]]; then + if [[ -z "${{ inputs.files }}" ]]; then echo "Getting diff..." From ce0e219f00203ed7a1f38cb36665377ac19842b1 Mon Sep 17 00:00:00 2001 From: Tonye Jack Date: Sat, 1 May 2021 08:01:13 -0400 Subject: [PATCH 06/29] Update action.yml --- action.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/action.yml b/action.yml index 6c5d1a16..7fcfce6b 100644 --- a/action.yml +++ b/action.yml @@ -57,8 +57,10 @@ runs: git fetch --depth=1 origin ${TARGET_BRANCH}:${TARGET_BRANCH} HEAD_SHA=$(git rev-parse ${TARGET_BRANCH} || true) fi + + INPUT_FILES="${{ inputs.files }}" - if [[ -z "${{ inputs.files }}" ]]; then + if [[ -z "$INPUT_FILES" ]]; then echo "Getting diff..." From 5b98ea4364330e5ae1a769f451a64ff86970b8bf Mon Sep 17 00:00:00 2001 From: Tonye Jack Date: Sat, 1 May 2021 08:02:50 -0400 Subject: [PATCH 07/29] Update action.yml --- action.yml | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/action.yml b/action.yml index 7fcfce6b..68685bd7 100644 --- a/action.yml +++ b/action.yml @@ -102,16 +102,16 @@ runs: do echo "Checking for file changes: \"${path}\"..." - ADDED_FILES+=$(git diff --diff-filter=A --name-only "$HEAD_SHA" | grep -E "(${path})") - COPIED_FILES+=$(git diff --diff-filter=C --name-only "$HEAD_SHA" | grep -E "(${path})") - DELETED_FILES+=$(git diff --diff-filter=D --name-only "$HEAD_SHA" | grep -E "(${path})") - MODIFIED_FILES+=$(git diff --diff-filter=M --name-only "$HEAD_SHA" | grep -E "(${path})") - RENAMED_FILES+=$(git diff --diff-filter=R --name-only "$HEAD_SHA" | grep -E "(${path})") - CHANGED_FILES+=$(git diff --diff-filter=T --name-only "$HEAD_SHA" | grep -E "(${path})") - UNMERGED_FILES+=$(git diff --diff-filter=U --name-only "$HEAD_SHA" | grep -E "(${path})") - UNKNOWN_FILES+=$(git diff --diff-filter=X --name-only "$HEAD_SHA" | grep -E "(${path})") - ALL_CHANGED+=$(git diff --diff-filter='*ACDMRTUX' --name-only "$HEAD_SHA" | grep -E "(${path})") - ALL_MODIFIED_FILES+=$(git diff --diff-filter='ACM' --name-only "$HEAD_SHA" | grep -E "(${path})") + ADDED_FILES+=$(git diff --diff-filter=A --name-only "$HEAD_SHA" | grep -E "(${path})" || true) + COPIED_FILES+=$(git diff --diff-filter=C --name-only "$HEAD_SHA" | grep -E "(${path})" || true) + DELETED_FILES+=$(git diff --diff-filter=D --name-only "$HEAD_SHA" | grep -E "(${path})" || true) + MODIFIED_FILES+=$(git diff --diff-filter=M --name-only "$HEAD_SHA" | grep -E "(${path})" || true) + RENAMED_FILES+=$(git diff --diff-filter=R --name-only "$HEAD_SHA" | grep -E "(${path})" || true) + CHANGED_FILES+=$(git diff --diff-filter=T --name-only "$HEAD_SHA" | grep -E "(${path})" || true) + UNMERGED_FILES+=$(git diff --diff-filter=U --name-only "$HEAD_SHA" | grep -E "(${path})" || true) + UNKNOWN_FILES+=$(git diff --diff-filter=X --name-only "$HEAD_SHA" | grep -E "(${path})" || true) + ALL_CHANGED+=$(git diff --diff-filter='*ACDMRTUX' --name-only "$HEAD_SHA" | grep -E "(${path})" || true) + ALL_MODIFIED_FILES+=$(git diff --diff-filter='ACM' --name-only "$HEAD_SHA" | grep -E "(${path})" || true) done From 254f56230ae9bdd80dffe1d1ec2073708a787683 Mon Sep 17 00:00:00 2001 From: Tonye Jack Date: Sat, 1 May 2021 08:14:27 -0400 Subject: [PATCH 08/29] Update action.yml --- action.yml | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/action.yml b/action.yml index 68685bd7..2f653d66 100644 --- a/action.yml +++ b/action.yml @@ -102,17 +102,17 @@ runs: do echo "Checking for file changes: \"${path}\"..." - ADDED_FILES+=$(git diff --diff-filter=A --name-only "$HEAD_SHA" | grep -E "(${path})" || true) - COPIED_FILES+=$(git diff --diff-filter=C --name-only "$HEAD_SHA" | grep -E "(${path})" || true) - DELETED_FILES+=$(git diff --diff-filter=D --name-only "$HEAD_SHA" | grep -E "(${path})" || true) - MODIFIED_FILES+=$(git diff --diff-filter=M --name-only "$HEAD_SHA" | grep -E "(${path})" || true) - RENAMED_FILES+=$(git diff --diff-filter=R --name-only "$HEAD_SHA" | grep -E "(${path})" || true) - CHANGED_FILES+=$(git diff --diff-filter=T --name-only "$HEAD_SHA" | grep -E "(${path})" || true) - UNMERGED_FILES+=$(git diff --diff-filter=U --name-only "$HEAD_SHA" | grep -E "(${path})" || true) - UNKNOWN_FILES+=$(git diff --diff-filter=X --name-only "$HEAD_SHA" | grep -E "(${path})" || true) - ALL_CHANGED+=$(git diff --diff-filter='*ACDMRTUX' --name-only "$HEAD_SHA" | grep -E "(${path})" || true) - ALL_MODIFIED_FILES+=$(git diff --diff-filter='ACM' --name-only "$HEAD_SHA" | grep -E "(${path})" || true) - + ADDED_FILES+="$(git diff --diff-filter=A --name-only "$HEAD_SHA" | grep -E "(${path})" || true)${{ inputs.separator }}" + COPIED_FILES+="$(git diff --diff-filter=C --name-only "$HEAD_SHA" | grep -E "(${path})" || true)${{ inputs.separator }}" + DELETED_FILES+="$(git diff --diff-filter=D --name-only "$HEAD_SHA" | grep -E "(${path})" || true)${{ inputs.separator }}" + MODIFIED_FILES+="$(git diff --diff-filter=M --name-only "$HEAD_SHA" | grep -E "(${path})" || true)${{ inputs.separator }}" + RENAMED_FILES+="$(git diff --diff-filter=R --name-only "$HEAD_SHA" | grep -E "(${path})" || true)${{ inputs.separator }}" + CHANGED_FILES+="$(git diff --diff-filter=T --name-only "$HEAD_SHA" | grep -E "(${path})" || true)${{ inputs.separator }}" + UNMERGED_FILES+="$(git diff --diff-filter=U --name-only "$HEAD_SHA" | grep -E "(${path})" || true)${{ inputs.separator }}" + UNKNOWN_FILES+="$(git diff --diff-filter=X --name-only "$HEAD_SHA" | grep -E "(${path})" || true)${{ inputs.separator }}" + ALL_CHANGED+="$(git diff --diff-filter='*ACDMRTUX' --name-only "$HEAD_SHA" | grep -E "(${path})" || true)${{ inputs.separator }}" + ALL_MODIFIED_FILES+="$(git diff --diff-filter='ACM' --name-only "$HEAD_SHA" | grep -E "(${path})" || true)${{ inputs.separator }}" +" done echo "::set-output name=added_files::$ADDED" From 1f7183322d4f172fc3bc694f58022053848efc83 Mon Sep 17 00:00:00 2001 From: Tonye Jack Date: Sat, 1 May 2021 08:25:21 -0400 Subject: [PATCH 09/29] Update action.yml --- action.yml | 59 +++++++++++++++++++++++++++--------------------------- 1 file changed, 30 insertions(+), 29 deletions(-) diff --git a/action.yml b/action.yml index 2f653d66..8b85dbfe 100644 --- a/action.yml +++ b/action.yml @@ -87,14 +87,14 @@ runs: echo "::set-output name=all_modified_files::$ALL_MODIFIED_FILES" else - ADDED_FILES=() - COPIED_FILES=() - DELETED_FILES=() - MODIFIED_FILES=() - RENAMED_FILES=() - CHANGED_FILES=() - UNMERGED_FILES=() - UNKNOWN_FILES=() + ADDED=() + COPIED=() + DELETED=() + MODIFIED=() + RENAMED=() + CHANGED=() + UNMERGED=() + UNKNOWN=() ALL_CHANGED=() ALL_MODIFIED_FILES=() @@ -102,29 +102,30 @@ runs: do echo "Checking for file changes: \"${path}\"..." - ADDED_FILES+="$(git diff --diff-filter=A --name-only "$HEAD_SHA" | grep -E "(${path})" || true)${{ inputs.separator }}" - COPIED_FILES+="$(git diff --diff-filter=C --name-only "$HEAD_SHA" | grep -E "(${path})" || true)${{ inputs.separator }}" - DELETED_FILES+="$(git diff --diff-filter=D --name-only "$HEAD_SHA" | grep -E "(${path})" || true)${{ inputs.separator }}" - MODIFIED_FILES+="$(git diff --diff-filter=M --name-only "$HEAD_SHA" | grep -E "(${path})" || true)${{ inputs.separator }}" - RENAMED_FILES+="$(git diff --diff-filter=R --name-only "$HEAD_SHA" | grep -E "(${path})" || true)${{ inputs.separator }}" - CHANGED_FILES+="$(git diff --diff-filter=T --name-only "$HEAD_SHA" | grep -E "(${path})" || true)${{ inputs.separator }}" - UNMERGED_FILES+="$(git diff --diff-filter=U --name-only "$HEAD_SHA" | grep -E "(${path})" || true)${{ inputs.separator }}" - UNKNOWN_FILES+="$(git diff --diff-filter=X --name-only "$HEAD_SHA" | grep -E "(${path})" || true)${{ inputs.separator }}" - ALL_CHANGED+="$(git diff --diff-filter='*ACDMRTUX' --name-only "$HEAD_SHA" | grep -E "(${path})" || true)${{ inputs.separator }}" - ALL_MODIFIED_FILES+="$(git diff --diff-filter='ACM' --name-only "$HEAD_SHA" | grep -E "(${path})" || true)${{ inputs.separator }}" -" + ADDED+=$(git diff --diff-filter=A --name-only "$HEAD_SHA" | grep -E "(${path})" || true) + COPIED+=$(git diff --diff-filter=C --name-only "$HEAD_SHA" | grep -E "(${path})" || true) + DELETED+=$(git diff --diff-filter=D --name-only "$HEAD_SHA" | grep -E "(${path})" || true) + MODIFIED+=$(git diff --diff-filter=M --name-only "$HEAD_SHA" | grep -E "(${path})" || true) + RENAMED+=$(git diff --diff-filter=R --name-only "$HEAD_SHA" | grep -E "(${path})" || true) + CHANGED+=$(git diff --diff-filter=T --name-only "$HEAD_SHA" | grep -E "(${path})" || true) + UNMERGED+=$(git diff --diff-filter=U --name-only "$HEAD_SHA" | grep -E "(${path})" || true) + UNKNOWN+=$(git diff --diff-filter=X --name-only "$HEAD_SHA" | grep -E "(${path})" || true) + ALL_CHANGED+=$(git diff --diff-filter='*ACDMRTUX' --name-only "$HEAD_SHA" | grep -E "(${path})" || true) + ALL_MODIFIED_FILES+=$(git diff --diff-filter='ACM' --name-only "$HEAD_SHA" | grep -E "(${path})" || true) done - echo "::set-output name=added_files::$ADDED" - echo "::set-output name=copied_files::$COPIED" - echo "::set-output name=deleted_files::$DELETED" - echo "::set-output name=modified_files::$MODIFIED" - echo "::set-output name=renamed_files::$RENAMED" - echo "::set-output name=changed_files::$CHANGED" - echo "::set-output name=unmerged_files::$UNMERGED" - echo "::set-output name=unknown_files::$UNKNOWN" - echo "::set-output name=all_changed_files::$ALL_CHANGED" - echo "::set-output name=all_modified_files::$ALL_MODIFIED_FILES" + IFS=${{ inputs.separator }} + + echo "::set-output name=added_files::${ADDED[*]}" + echo "::set-output name=copied_files::${COPIED[*]}" + echo "::set-output name=deleted_files::${DELETED[*]}" + echo "::set-output name=modified_files::${MODIFIED[*]}" + echo "::set-output name=renamed_files::${RENAMED[*]}" + echo "::set-output name=changed_files::${CHANGED[*]}" + echo "::set-output name=unmerged_files::${UNMERGED[*]}" + echo "::set-output name=unknown_files::${UNKNOWN[*]}" + echo "::set-output name=all_changed_files::${ALL_CHANGED[*]}" + echo "::set-output name=all_modified_files::${ALL_MODIFIED_FILES[*]}" fi shell: bash From 570809f09a2f030293497677d3b86bf9ab47e040 Mon Sep 17 00:00:00 2001 From: Tonye Jack Date: Sat, 1 May 2021 08:31:24 -0400 Subject: [PATCH 10/29] Update action.yml --- action.yml | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/action.yml b/action.yml index 8b85dbfe..669d6b78 100644 --- a/action.yml +++ b/action.yml @@ -112,20 +112,19 @@ runs: UNKNOWN+=$(git diff --diff-filter=X --name-only "$HEAD_SHA" | grep -E "(${path})" || true) ALL_CHANGED+=$(git diff --diff-filter='*ACDMRTUX' --name-only "$HEAD_SHA" | grep -E "(${path})" || true) ALL_MODIFIED_FILES+=$(git diff --diff-filter='ACM' --name-only "$HEAD_SHA" | grep -E "(${path})" || true) + done - IFS=${{ inputs.separator }} - - echo "::set-output name=added_files::${ADDED[*]}" - echo "::set-output name=copied_files::${COPIED[*]}" - echo "::set-output name=deleted_files::${DELETED[*]}" - echo "::set-output name=modified_files::${MODIFIED[*]}" - echo "::set-output name=renamed_files::${RENAMED[*]}" - echo "::set-output name=changed_files::${CHANGED[*]}" - echo "::set-output name=unmerged_files::${UNMERGED[*]}" - echo "::set-output name=unknown_files::${UNKNOWN[*]}" - echo "::set-output name=all_changed_files::${ALL_CHANGED[*]}" - echo "::set-output name=all_modified_files::${ALL_MODIFIED_FILES[*]}" + echo "::set-output name=added_files::$(IFS='${{ inputs.separator }}'; echo '${ADDED[*]}')" + echo "::set-output name=copied_files::$(IFS='${{ inputs.separator }}'; echo '${COPIED[*]}'" + echo "::set-output name=deleted_files::$(IFS='${{ inputs.separator }}'; echo '${DELETED[*]}'" + echo "::set-output name=modified_files::$(IFS='${{ inputs.separator }}'; echo '${MODIFIED[*]}'" + echo "::set-output name=renamed_files::$(IFS='${{ inputs.separator }}'; echo '${RENAMED[*]}'" + echo "::set-output name=changed_files::$(IFS='${{ inputs.separator }}'; echo '${CHANGED[*]}'" + echo "::set-output name=unmerged_files::$(IFS='${{ inputs.separator }}'; echo '${UNMERGED[*]}'" + echo "::set-output name=unknown_files::$(IFS='${{ inputs.separator }}'; echo '${UNKNOWN[*]}'" + echo "::set-output name=all_changed_files::$(IFS='${{ inputs.separator }}'; echo '${ALL_CHANGED[*]}'" + echo "::set-output name=all_modified_files::$(IFS='${{ inputs.separator }}'; echo '${ALL_MODIFIED_FILES[*]}'" fi shell: bash From 858bda29ab5325ebeae1161b80758a6acd208b45 Mon Sep 17 00:00:00 2001 From: Tonye Jack Date: Sat, 1 May 2021 08:52:22 -0400 Subject: [PATCH 11/29] Update action.yml --- action.yml | 35 +++++++++++++++++++++++------------ 1 file changed, 23 insertions(+), 12 deletions(-) diff --git a/action.yml b/action.yml index 669d6b78..4e39bee3 100644 --- a/action.yml +++ b/action.yml @@ -101,7 +101,6 @@ runs: for path in ${INPUT_FILES} do echo "Checking for file changes: \"${path}\"..." - ADDED+=$(git diff --diff-filter=A --name-only "$HEAD_SHA" | grep -E "(${path})" || true) COPIED+=$(git diff --diff-filter=C --name-only "$HEAD_SHA" | grep -E "(${path})" || true) DELETED+=$(git diff --diff-filter=D --name-only "$HEAD_SHA" | grep -E "(${path})" || true) @@ -112,19 +111,31 @@ runs: UNKNOWN+=$(git diff --diff-filter=X --name-only "$HEAD_SHA" | grep -E "(${path})" || true) ALL_CHANGED+=$(git diff --diff-filter='*ACDMRTUX' --name-only "$HEAD_SHA" | grep -E "(${path})" || true) ALL_MODIFIED_FILES+=$(git diff --diff-filter='ACM' --name-only "$HEAD_SHA" | grep -E "(${path})" || true) - done - echo "::set-output name=added_files::$(IFS='${{ inputs.separator }}'; echo '${ADDED[*]}')" - echo "::set-output name=copied_files::$(IFS='${{ inputs.separator }}'; echo '${COPIED[*]}'" - echo "::set-output name=deleted_files::$(IFS='${{ inputs.separator }}'; echo '${DELETED[*]}'" - echo "::set-output name=modified_files::$(IFS='${{ inputs.separator }}'; echo '${MODIFIED[*]}'" - echo "::set-output name=renamed_files::$(IFS='${{ inputs.separator }}'; echo '${RENAMED[*]}'" - echo "::set-output name=changed_files::$(IFS='${{ inputs.separator }}'; echo '${CHANGED[*]}'" - echo "::set-output name=unmerged_files::$(IFS='${{ inputs.separator }}'; echo '${UNMERGED[*]}'" - echo "::set-output name=unknown_files::$(IFS='${{ inputs.separator }}'; echo '${UNKNOWN[*]}'" - echo "::set-output name=all_changed_files::$(IFS='${{ inputs.separator }}'; echo '${ALL_CHANGED[*]}'" - echo "::set-output name=all_modified_files::$(IFS='${{ inputs.separator }}'; echo '${ALL_MODIFIED_FILES[*]}'" + IFS="${{ inputs.separator }}" + + ADDED=$(echo "${ADDED[*]}") + COPIED=$(echo "${COPIED[*]}") + DELETED=$(echo "${DELETED[*]}") + MODIFIED=$(echo "${MODIFIED[*]}") + RENAMED=$(echo "${RENAMED[*]}") + CHANGED=$(echo "${CHANGED[*]}") + UNMERGED=$(echo "${UNMERGED[*]}") + UNKNOWN=$(echo "${UNKNOWN[*]}") + ALL_CHANGED=$(echo "${ALL_CHANGED[*]}") + ALL_MODIFIED_FILES=$(echo "${ALL_MODIFIED_FILES[*]}") + + echo "::set-output name=added_files::$ADDED" + echo "::set-output name=copied_files::$COPIED" + echo "::set-output name=deleted_files::$DELETED" + echo "::set-output name=modified_files::$MODIFIED" + echo "::set-output name=renamed_files::$RENAMED" + echo "::set-output name=changed_files::$CHANGED" + echo "::set-output name=unmerged_files::$UNMERGED" + echo "::set-output name=unknown_files::$UNKNOWN" + echo "::set-output name=all_changed_files::$ALL_CHANGED" + echo "::set-output name=all_modified_files::$ALL_MODIFIED_FILES" fi shell: bash From 41c5eb7faa2a16c1b49bb6ec5fba7847449db033 Mon Sep 17 00:00:00 2001 From: Tonye Jack Date: Sat, 1 May 2021 08:53:56 -0400 Subject: [PATCH 12/29] Update action.yml --- action.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/action.yml b/action.yml index 4e39bee3..66d2e354 100644 --- a/action.yml +++ b/action.yml @@ -113,7 +113,7 @@ runs: ALL_MODIFIED_FILES+=$(git diff --diff-filter='ACM' --name-only "$HEAD_SHA" | grep -E "(${path})" || true) done - IFS="${{ inputs.separator }}" + export IFS=${{ inputs.separator }} ADDED=$(echo "${ADDED[*]}") COPIED=$(echo "${COPIED[*]}") From 932c8a5c11679a6e00560eb2234df35a729fb89d Mon Sep 17 00:00:00 2001 From: Tonye Jack Date: Sat, 1 May 2021 08:57:11 -0400 Subject: [PATCH 13/29] Update action.yml --- action.yml | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/action.yml b/action.yml index 66d2e354..4fbeac34 100644 --- a/action.yml +++ b/action.yml @@ -113,18 +113,16 @@ runs: ALL_MODIFIED_FILES+=$(git diff --diff-filter='ACM' --name-only "$HEAD_SHA" | grep -E "(${path})" || true) done - export IFS=${{ inputs.separator }} - - ADDED=$(echo "${ADDED[*]}") - COPIED=$(echo "${COPIED[*]}") - DELETED=$(echo "${DELETED[*]}") - MODIFIED=$(echo "${MODIFIED[*]}") - RENAMED=$(echo "${RENAMED[*]}") - CHANGED=$(echo "${CHANGED[*]}") - UNMERGED=$(echo "${UNMERGED[*]}") - UNKNOWN=$(echo "${UNKNOWN[*]}") - ALL_CHANGED=$(echo "${ALL_CHANGED[*]}") - ALL_MODIFIED_FILES=$(echo "${ALL_MODIFIED_FILES[*]}") + ADDED=$(IFS="${{ inputs.separator }}"; echo "${ADDED[*]}") + COPIED=$(IFS="${{ inputs.separator }}"; echo "${COPIED[*]}") + DELETED=$(IFS="${{ inputs.separator }}"; echo "${DELETED[*]}") + MODIFIED=$(IFS="${{ inputs.separator }}"; echo "${MODIFIED[*]}") + RENAMED=$(IFS="${{ inputs.separator }}"; echo "${RENAMED[*]}") + CHANGED=$(IFS="${{ inputs.separator }}"; echo "${CHANGED[*]}") + UNMERGED=$(IFS="${{ inputs.separator }}"; echo "${UNMERGED[*]}") + UNKNOWN=$(IFS="${{ inputs.separator }}"; echo "${UNKNOWN[*]}") + ALL_CHANGED=$(IFS="${{ inputs.separator }}"; echo "${ALL_CHANGED[*]}") + ALL_MODIFIED_FILES=$(IFS="${{ inputs.separator }}"; echo "${ALL_MODIFIED_FILES[*]}") echo "::set-output name=added_files::$ADDED" echo "::set-output name=copied_files::$COPIED" From 7841015a94e114d53c9d309dd7bad77eb4f5e105 Mon Sep 17 00:00:00 2001 From: Tonye Jack Date: Sat, 1 May 2021 08:59:18 -0400 Subject: [PATCH 14/29] Update test.yml --- .github/workflows/test.yml | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 613115ea..60097e9e 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -50,3 +50,14 @@ jobs: - name: Show output run: | echo "${{ toJSON(steps.changed-files-specific.outputs) }}" + - name: Run changed-files with specific files comma separator + id: changed-files-specific-comma + uses: ./ + with: + files: | + action.yml + .github/workflows/test.yml + separator: "," + - name: Show output + run: | + echo "${{ toJSON(steps.changed-files-specific-comma.outputs) }}" From fdc23e7274f8905e76645235aa3618411b3e9753 Mon Sep 17 00:00:00 2001 From: Tonye Jack Date: Sat, 1 May 2021 09:06:55 -0400 Subject: [PATCH 15/29] Update action.yml --- action.yml | 40 ++++++++++++++++++++-------------------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/action.yml b/action.yml index 4fbeac34..689b8aa6 100644 --- a/action.yml +++ b/action.yml @@ -101,28 +101,28 @@ runs: for path in ${INPUT_FILES} do echo "Checking for file changes: \"${path}\"..." - ADDED+=$(git diff --diff-filter=A --name-only "$HEAD_SHA" | grep -E "(${path})" || true) - COPIED+=$(git diff --diff-filter=C --name-only "$HEAD_SHA" | grep -E "(${path})" || true) - DELETED+=$(git diff --diff-filter=D --name-only "$HEAD_SHA" | grep -E "(${path})" || true) - MODIFIED+=$(git diff --diff-filter=M --name-only "$HEAD_SHA" | grep -E "(${path})" || true) - RENAMED+=$(git diff --diff-filter=R --name-only "$HEAD_SHA" | grep -E "(${path})" || true) - CHANGED+=$(git diff --diff-filter=T --name-only "$HEAD_SHA" | grep -E "(${path})" || true) - UNMERGED+=$(git diff --diff-filter=U --name-only "$HEAD_SHA" | grep -E "(${path})" || true) - UNKNOWN+=$(git diff --diff-filter=X --name-only "$HEAD_SHA" | grep -E "(${path})" || true) - ALL_CHANGED+=$(git diff --diff-filter='*ACDMRTUX' --name-only "$HEAD_SHA" | grep -E "(${path})" || true) - ALL_MODIFIED_FILES+=$(git diff --diff-filter='ACM' --name-only "$HEAD_SHA" | grep -E "(${path})" || true) + ADDED+=$(git diff --diff-filter=A --name-only "$HEAD_SHA" | grep -E "(${path})" | xargs printf "%s${{ inputs.separator }}" || true) + COPIED+=$(git diff --diff-filter=C --name-only "$HEAD_SHA" | grep -E "(${path})" | xargs printf "%s${{ inputs.separator }}" || true) + DELETED+=$(git diff --diff-filter=D --name-only "$HEAD_SHA" | grep -E "(${path})" | xargs printf "%s${{ inputs.separator }}" || true) + MODIFIED+=$(git diff --diff-filter=M --name-only "$HEAD_SHA" | grep -E "(${path})" | xargs printf "%s${{ inputs.separator }}" || true) + RENAMED+=$(git diff --diff-filter=R --name-only "$HEAD_SHA" | grep -E "(${path})" | xargs printf "%s${{ inputs.separator }}" || true) + CHANGED+=$(git diff --diff-filter=T --name-only "$HEAD_SHA" | grep -E "(${path})" | xargs printf "%s${{ inputs.separator }}" || true) + UNMERGED+=$(git diff --diff-filter=U --name-only "$HEAD_SHA" | grep -E "(${path})" | xargs printf "%s${{ inputs.separator }}" || true) + UNKNOWN+=$(git diff --diff-filter=X --name-only "$HEAD_SHA" | grep -E "(${path})" | xargs printf "%s${{ inputs.separator }}" || true) + ALL_CHANGED+=$(git diff --diff-filter='*ACDMRTUX' --name-only "$HEAD_SHA" | grep -E "(${path})" | xargs printf "%s${{ inputs.separator }}" || true) + ALL_MODIFIED_FILES+=$(git diff --diff-filter='ACM' --name-only "$HEAD_SHA" | grep -E "(${path})" | xargs printf "%s${{ inputs.separator }}" || true) done - ADDED=$(IFS="${{ inputs.separator }}"; echo "${ADDED[*]}") - COPIED=$(IFS="${{ inputs.separator }}"; echo "${COPIED[*]}") - DELETED=$(IFS="${{ inputs.separator }}"; echo "${DELETED[*]}") - MODIFIED=$(IFS="${{ inputs.separator }}"; echo "${MODIFIED[*]}") - RENAMED=$(IFS="${{ inputs.separator }}"; echo "${RENAMED[*]}") - CHANGED=$(IFS="${{ inputs.separator }}"; echo "${CHANGED[*]}") - UNMERGED=$(IFS="${{ inputs.separator }}"; echo "${UNMERGED[*]}") - UNKNOWN=$(IFS="${{ inputs.separator }}"; echo "${UNKNOWN[*]}") - ALL_CHANGED=$(IFS="${{ inputs.separator }}"; echo "${ALL_CHANGED[*]}") - ALL_MODIFIED_FILES=$(IFS="${{ inputs.separator }}"; echo "${ALL_MODIFIED_FILES[*]}") + ADDED=$(echo "$ADDED" | sed -E 's/(${{ inputs.separator }})$//') + COPIED=$(echo $COPIED | sed -E 's/(${{ inputs.separator }})$//') + DELETED=$(echo "$DELETED" | sed -E 's/(${{ inputs.separator }})$//') + MODIFIED=$(echo "$MODIFIED" | sed -E 's/(${{ inputs.separator }})$//') + RENAMED=$(echo "$RENAMED" | sed -E 's/(${{ inputs.separator }})$//') + CHANGED=$(echo "$CHANGED" | sed -E 's/(${{ inputs.separator }})$//') + UNMERGED=$(echo "$UNMERGED" | sed -E 's/(${{ inputs.separator }})$//') + UNKNOWN=$(echo "$UNKNOWN" | sed -E 's/(${{ inputs.separator }})$//') + ALL_CHANGED=$(echo "$ALL_CHANGED" | sed -E 's/(${{ inputs.separator }})$//') + ALL_MODIFIED_FILES=$(echo "$ALL_MODIFIED_FILES" | sed -E 's/(${{ inputs.separator }})$//') echo "::set-output name=added_files::$ADDED" echo "::set-output name=copied_files::$COPIED" From 1e435854e368c5e0d588594a49b991a8c5873aa5 Mon Sep 17 00:00:00 2001 From: Tonye Jack Date: Sat, 1 May 2021 09:14:27 -0400 Subject: [PATCH 16/29] Update action.yml --- action.yml | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/action.yml b/action.yml index 689b8aa6..1f46db48 100644 --- a/action.yml +++ b/action.yml @@ -123,6 +123,14 @@ runs: UNKNOWN=$(echo "$UNKNOWN" | sed -E 's/(${{ inputs.separator }})$//') ALL_CHANGED=$(echo "$ALL_CHANGED" | sed -E 's/(${{ inputs.separator }})$//') ALL_MODIFIED_FILES=$(echo "$ALL_MODIFIED_FILES" | sed -E 's/(${{ inputs.separator }})$//') + + SEP_INPUT_FILES=$(echo $INPUT_FILES || sed -E 's/ /(${{ inputs.separator }})/') + + if [[ $ALL_MODIFIED_FILES -eq $SEP_INPUT_FILES ]]; then + echo "::set-output name=has_changes::true" + else + echo "::set-output name=has_changes::false" + fi echo "::set-output name=added_files::$ADDED" echo "::set-output name=copied_files::$COPIED" From b1f6992ec2fe0a9001e46821aa72434bb3bd7247 Mon Sep 17 00:00:00 2001 From: Tonye Jack Date: Sat, 1 May 2021 09:15:25 -0400 Subject: [PATCH 17/29] Update action.yml --- action.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/action.yml b/action.yml index 1f46db48..680a94f1 100644 --- a/action.yml +++ b/action.yml @@ -124,7 +124,7 @@ runs: ALL_CHANGED=$(echo "$ALL_CHANGED" | sed -E 's/(${{ inputs.separator }})$//') ALL_MODIFIED_FILES=$(echo "$ALL_MODIFIED_FILES" | sed -E 's/(${{ inputs.separator }})$//') - SEP_INPUT_FILES=$(echo $INPUT_FILES || sed -E 's/ /(${{ inputs.separator }})/') + SEP_INPUT_FILES=$(echo $INPUT_FILES || sed -E 's/ /(${{ inputs.separator }})/g') if [[ $ALL_MODIFIED_FILES -eq $SEP_INPUT_FILES ]]; then echo "::set-output name=has_changes::true" From 3d1254080650bb62b3fabb5366595f4f03204538 Mon Sep 17 00:00:00 2001 From: Tonye Jack Date: Sat, 1 May 2021 09:17:04 -0400 Subject: [PATCH 18/29] Update action.yml --- action.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/action.yml b/action.yml index 680a94f1..baac43d3 100644 --- a/action.yml +++ b/action.yml @@ -127,9 +127,9 @@ runs: SEP_INPUT_FILES=$(echo $INPUT_FILES || sed -E 's/ /(${{ inputs.separator }})/g') if [[ $ALL_MODIFIED_FILES -eq $SEP_INPUT_FILES ]]; then - echo "::set-output name=has_changes::true" + echo "::set-output name=has_changed::true" else - echo "::set-output name=has_changes::false" + echo "::set-output name=has_changed::false" fi echo "::set-output name=added_files::$ADDED" From 168ea27d9cb1f9ca1bcbf86b2896ec64e5bb812a Mon Sep 17 00:00:00 2001 From: Tonye Jack Date: Sat, 1 May 2021 09:18:46 -0400 Subject: [PATCH 19/29] Update README.md --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index b029221c..dca0a408 100644 --- a/README.md +++ b/README.md @@ -25,6 +25,7 @@ Using the default separator. | Output | type | example | description | |:-------------------:|:------------:|:------------------------------:|:----------------------------------------:| | all_modified_files | `string` | 'new.txt other.png ...' | Select all modified files
*i.e a combination of all added,
copied and modified files (ACM).* | +| has_changed | `string` | `true|false` | Returns `true` only when the filenames provided using `files` input have all changed | | all_changed_files | `string` | 'new.txt other.png ...' | Select all paths (*)
*i.e a combination of all options below.* | | added_files | `string` | 'new.txt other.png ...' | Select only files that are Added (A) | | copied_files | `string` | 'new.txt other.png ...' | Select only files that are Copied (C) | From 79272641ee1d3a46298ab97cea541ad55feba4d1 Mon Sep 17 00:00:00 2001 From: Tonye Jack Date: Sat, 1 May 2021 09:21:41 -0400 Subject: [PATCH 20/29] Update action.yml --- action.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/action.yml b/action.yml index baac43d3..f141c363 100644 --- a/action.yml +++ b/action.yml @@ -42,6 +42,9 @@ outputs: all_modified_files: description: List of all copied modified and added files value: ${{ steps.changed_files.outputs.all_modified_files }} + has_changed: + description: Return true only when all files provided using the files input have all changed. + value: ${{ steps.changed_files.outputs.has_changed }} runs: using: 'composite' From bca6aacc4512780b12f639ce3d3e1e6aecebbd1f Mon Sep 17 00:00:00 2001 From: Tonye Jack Date: Sat, 1 May 2021 09:32:01 -0400 Subject: [PATCH 21/29] Update action.yml --- action.yml | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/action.yml b/action.yml index f141c363..fc2f039a 100644 --- a/action.yml +++ b/action.yml @@ -127,9 +127,12 @@ runs: ALL_CHANGED=$(echo "$ALL_CHANGED" | sed -E 's/(${{ inputs.separator }})$//') ALL_MODIFIED_FILES=$(echo "$ALL_MODIFIED_FILES" | sed -E 's/(${{ inputs.separator }})$//') - SEP_INPUT_FILES=$(echo $INPUT_FILES || sed -E 's/ /(${{ inputs.separator }})/g') + OUTPUT_ALL_MODIFIED_FILES=$(echo $ALL_MODIFIED_FILES | sed "s/(${{ inputs.separator }})/ /g") - if [[ $ALL_MODIFIED_FILES -eq $SEP_INPUT_FILES ]]; then + IFS=$'\n' SORTED_INPUT_FILES=($(sort <<<"${INPUT_FILES[*]}")) + IFS=$'\n' SORTED_OUTPUT_ALL_MODIFIED_FILES=($(sort <<<"${OUTPUT_ALL_MODIFIED_FILES[*]}")) + + if [[ $SORTED_INPUT_FILES -eq $SORTED_OUTPUT_ALL_MODIFIED_FILES ]]; then echo "::set-output name=has_changed::true" else echo "::set-output name=has_changed::false" From 95ef6d6cbd035921e6c40c00c2f2ac73fd62df90 Mon Sep 17 00:00:00 2001 From: Tonye Jack Date: Sat, 1 May 2021 09:36:57 -0400 Subject: [PATCH 22/29] Update action.yml --- action.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/action.yml b/action.yml index fc2f039a..9c44c296 100644 --- a/action.yml +++ b/action.yml @@ -132,7 +132,7 @@ runs: IFS=$'\n' SORTED_INPUT_FILES=($(sort <<<"${INPUT_FILES[*]}")) IFS=$'\n' SORTED_OUTPUT_ALL_MODIFIED_FILES=($(sort <<<"${OUTPUT_ALL_MODIFIED_FILES[*]}")) - if [[ $SORTED_INPUT_FILES -eq $SORTED_OUTPUT_ALL_MODIFIED_FILES ]]; then + if [[ "${SORTED_INPUT_FILES[*]}" == "${SORTED_OUTPUT_ALL_MODIFIED_FILES[*]}" ]]; then echo "::set-output name=has_changed::true" else echo "::set-output name=has_changed::false" From 86c601796730c0579f0e3088b6fda06240cf87eb Mon Sep 17 00:00:00 2001 From: Tonye Jack Date: Sat, 1 May 2021 09:59:48 -0400 Subject: [PATCH 23/29] Update action.yml --- action.yml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/action.yml b/action.yml index 9c44c296..31d80a23 100644 --- a/action.yml +++ b/action.yml @@ -129,9 +129,14 @@ runs: OUTPUT_ALL_MODIFIED_FILES=$(echo $ALL_MODIFIED_FILES | sed "s/(${{ inputs.separator }})/ /g") + echo $OUTPUT_ALL_MODIFIED_FILES + IFS=$'\n' SORTED_INPUT_FILES=($(sort <<<"${INPUT_FILES[*]}")) IFS=$'\n' SORTED_OUTPUT_ALL_MODIFIED_FILES=($(sort <<<"${OUTPUT_ALL_MODIFIED_FILES[*]}")) + echo $SORTED_INPUT_FILES + echo $SORTED_OUTPUT_ALL_MODIFIED_FILES + if [[ "${SORTED_INPUT_FILES[*]}" == "${SORTED_OUTPUT_ALL_MODIFIED_FILES[*]}" ]]; then echo "::set-output name=has_changed::true" else From eacc41714667e335e132827d299bb9ca7a95ef1f Mon Sep 17 00:00:00 2001 From: Tonye Jack Date: Sat, 1 May 2021 10:10:12 -0400 Subject: [PATCH 24/29] Update action.yml --- action.yml | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/action.yml b/action.yml index 31d80a23..1b2c46b2 100644 --- a/action.yml +++ b/action.yml @@ -128,15 +128,11 @@ runs: ALL_MODIFIED_FILES=$(echo "$ALL_MODIFIED_FILES" | sed -E 's/(${{ inputs.separator }})$//') OUTPUT_ALL_MODIFIED_FILES=$(echo $ALL_MODIFIED_FILES | sed "s/(${{ inputs.separator }})/ /g") + ALL_INPUT_FILES=${INPUT_FILES/\\n/ } - echo $OUTPUT_ALL_MODIFIED_FILES - - IFS=$'\n' SORTED_INPUT_FILES=($(sort <<<"${INPUT_FILES[*]}")) + IFS=$'\n' SORTED_INPUT_FILES=($(sort <<<"${ALL_INPUT_FILES[*]}")) IFS=$'\n' SORTED_OUTPUT_ALL_MODIFIED_FILES=($(sort <<<"${OUTPUT_ALL_MODIFIED_FILES[*]}")) - echo $SORTED_INPUT_FILES - echo $SORTED_OUTPUT_ALL_MODIFIED_FILES - if [[ "${SORTED_INPUT_FILES[*]}" == "${SORTED_OUTPUT_ALL_MODIFIED_FILES[*]}" ]]; then echo "::set-output name=has_changed::true" else From 461fb0a6768ebc25bfbb6968df4cb62e9b84f98d Mon Sep 17 00:00:00 2001 From: Tonye Jack Date: Sat, 1 May 2021 10:24:26 -0400 Subject: [PATCH 25/29] Update action.yml --- action.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/action.yml b/action.yml index 1b2c46b2..ff4cbdd7 100644 --- a/action.yml +++ b/action.yml @@ -128,7 +128,7 @@ runs: ALL_MODIFIED_FILES=$(echo "$ALL_MODIFIED_FILES" | sed -E 's/(${{ inputs.separator }})$//') OUTPUT_ALL_MODIFIED_FILES=$(echo $ALL_MODIFIED_FILES | sed "s/(${{ inputs.separator }})/ /g") - ALL_INPUT_FILES=${INPUT_FILES/\\n/ } + ALL_INPUT_FILES=$(echo $INPUT_FILES | sed "s/\n/ /g") IFS=$'\n' SORTED_INPUT_FILES=($(sort <<<"${ALL_INPUT_FILES[*]}")) IFS=$'\n' SORTED_OUTPUT_ALL_MODIFIED_FILES=($(sort <<<"${OUTPUT_ALL_MODIFIED_FILES[*]}")) From 1378377c4f48fe62e06aab62cc2faf356655adb9 Mon Sep 17 00:00:00 2001 From: Tonye Jack Date: Sat, 1 May 2021 10:44:33 -0400 Subject: [PATCH 26/29] Update action.yml --- action.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/action.yml b/action.yml index ff4cbdd7..03a3ecd0 100644 --- a/action.yml +++ b/action.yml @@ -130,9 +130,13 @@ runs: OUTPUT_ALL_MODIFIED_FILES=$(echo $ALL_MODIFIED_FILES | sed "s/(${{ inputs.separator }})/ /g") ALL_INPUT_FILES=$(echo $INPUT_FILES | sed "s/\n/ /g") + echo "Files: $OUTPUT_ALL_MODIFIED_FILES != $ALL_INPUT_FILES" + IFS=$'\n' SORTED_INPUT_FILES=($(sort <<<"${ALL_INPUT_FILES[*]}")) IFS=$'\n' SORTED_OUTPUT_ALL_MODIFIED_FILES=($(sort <<<"${OUTPUT_ALL_MODIFIED_FILES[*]}")) + echo "Files: $SORTED_INPUT_FILES != $SORTED_OUTPUT_ALL_MODIFIED_FILES" + if [[ "${SORTED_INPUT_FILES[*]}" == "${SORTED_OUTPUT_ALL_MODIFIED_FILES[*]}" ]]; then echo "::set-output name=has_changed::true" else From 1137222c3383a24ea0be97c322a0a657be2ab481 Mon Sep 17 00:00:00 2001 From: Tonye Jack Date: Sat, 1 May 2021 12:03:23 -0400 Subject: [PATCH 27/29] Update action.yml --- action.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/action.yml b/action.yml index 03a3ecd0..0bf27d7e 100644 --- a/action.yml +++ b/action.yml @@ -127,7 +127,7 @@ runs: ALL_CHANGED=$(echo "$ALL_CHANGED" | sed -E 's/(${{ inputs.separator }})$//') ALL_MODIFIED_FILES=$(echo "$ALL_MODIFIED_FILES" | sed -E 's/(${{ inputs.separator }})$//') - OUTPUT_ALL_MODIFIED_FILES=$(echo $ALL_MODIFIED_FILES | sed "s/(${{ inputs.separator }})/ /g") + OUTPUT_ALL_MODIFIED_FILES=$(echo $ALL_MODIFIED_FILES | sed "s/${{ inputs.separator }}/ /g") ALL_INPUT_FILES=$(echo $INPUT_FILES | sed "s/\n/ /g") echo "Files: $OUTPUT_ALL_MODIFIED_FILES != $ALL_INPUT_FILES" From db67c2c65fb83aeaef7503e6e26e87396478677f Mon Sep 17 00:00:00 2001 From: Tonye Jack Date: Sat, 1 May 2021 12:05:17 -0400 Subject: [PATCH 28/29] Update action.yml --- action.yml | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/action.yml b/action.yml index 0bf27d7e..f3e0d22f 100644 --- a/action.yml +++ b/action.yml @@ -129,14 +129,10 @@ runs: OUTPUT_ALL_MODIFIED_FILES=$(echo $ALL_MODIFIED_FILES | sed "s/${{ inputs.separator }}/ /g") ALL_INPUT_FILES=$(echo $INPUT_FILES | sed "s/\n/ /g") - - echo "Files: $OUTPUT_ALL_MODIFIED_FILES != $ALL_INPUT_FILES" - + IFS=$'\n' SORTED_INPUT_FILES=($(sort <<<"${ALL_INPUT_FILES[*]}")) IFS=$'\n' SORTED_OUTPUT_ALL_MODIFIED_FILES=($(sort <<<"${OUTPUT_ALL_MODIFIED_FILES[*]}")) - echo "Files: $SORTED_INPUT_FILES != $SORTED_OUTPUT_ALL_MODIFIED_FILES" - if [[ "${SORTED_INPUT_FILES[*]}" == "${SORTED_OUTPUT_ALL_MODIFIED_FILES[*]}" ]]; then echo "::set-output name=has_changed::true" else From 8e1fd96840e1d9f382c8c45826d79370e3a821d6 Mon Sep 17 00:00:00 2001 From: Tonye Jack Date: Sat, 1 May 2021 12:10:19 -0400 Subject: [PATCH 29/29] Update README.md --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index dca0a408..d030d053 100644 --- a/README.md +++ b/README.md @@ -25,7 +25,7 @@ Using the default separator. | Output | type | example | description | |:-------------------:|:------------:|:------------------------------:|:----------------------------------------:| | all_modified_files | `string` | 'new.txt other.png ...' | Select all modified files
*i.e a combination of all added,
copied and modified files (ACM).* | -| has_changed | `string` | `true|false` | Returns `true` only when the filenames provided using `files` input have all changed | +| has_changed | `string` | `true OR false` | Returns `true` only when the filenames provided using `files` input have all changed | | all_changed_files | `string` | 'new.txt other.png ...' | Select all paths (*)
*i.e a combination of all options below.* | | added_files | `string` | 'new.txt other.png ...' | Select only files that are Added (A) | | copied_files | `string` | 'new.txt other.png ...' | Select only files that are Copied (C) | @@ -42,7 +42,7 @@ Using the default separator. | Input | type | required | default | description | |:-------------:|:-----------:|:-------------:|:----------------------------:|:-------------:| | separator | `string` | `true` | `' '` | Separator to return outputs | -| files | `string|string[]` | `false` | | Restricted list of specific files to watch for changes | +| files | `string OR string[]` | `false` | | Restricted list of specific files to watch for changes | ## Usage