From 9cc7563ef7fa5cfa1aabf480dffdb4f0a2d8b1aa Mon Sep 17 00:00:00 2001 From: Tonye Jack Date: Sat, 4 Sep 2021 09:31:19 -0400 Subject: [PATCH] Update other_changed_files output to also use the separator (#186) --- .github/workflows/update-readme.yml | 2 ++ entrypoint.sh | 17 ++++++++++------- 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/.github/workflows/update-readme.yml b/.github/workflows/update-readme.yml index a86ffb30..716b8772 100644 --- a/.github/workflows/update-readme.yml +++ b/.github/workflows/update-readme.yml @@ -22,11 +22,13 @@ jobs: with: files: | README.md + - name: README.md changed if: steps.verify_changed_files.outputs.files_changed == 'true' run: | echo "README.md has uncommited changes" exit 1 + - name: Create Pull Request if: failure() uses: peter-evans/create-pull-request@v3 diff --git a/entrypoint.sh b/entrypoint.sh index 268bf1ec..b8eb4325 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -86,6 +86,8 @@ else ALL_CHANGED_ARRAY=() ALL_MODIFIED_FILES_ARRAY=() + echo "Input files: ${INPUT_FILES[*]}" + for path in ${INPUT_FILES} do echo "Checking for file changes: \"${path}\"..." @@ -124,20 +126,21 @@ else ALL_MODIFIED_FILES=$(echo "${ALL_MODIFIED_FILES_ARRAY[*]}" | tr " " "\n" | sort -u | awk -v d="$INPUT_SEPARATOR" '{s=(NR==1?s:s d)$0}END{print s}') ALL_OTHER_CHANGED_FILES=$(git diff --diff-filter="ACMR" --name-only "$PREVIOUS_SHA" "$CURRENT_SHA") - IFS=" " read -r -a UNIQUE_ALL_MODIFIED_FILES <<< "$(echo "${ALL_MODIFIED_FILES_ARRAY[*]}" | tr " " "\n" | sort -u | tr "\n" " ")" - IFS=" " read -r -a OTHER_CHANGED_FILES <<< "$(echo "${ALL_OTHER_CHANGED_FILES[@]}" "${UNIQUE_ALL_MODIFIED_FILES[@]}" | tr " " "\n" | sort | uniq -u | tr "\n" " ")" + IFS=" " read -r -a UNIQUE_ALL_MODIFIED_FILES_ARRAY <<< "$(echo "${ALL_MODIFIED_FILES_ARRAY[*]}" | tr " " "\n" | sort -u | tr "\n" " ")" + IFS=" " read -r -a OTHER_CHANGED_FILES_ARRAY <<< "$(echo "${ALL_OTHER_CHANGED_FILES[@]}" "${UNIQUE_ALL_MODIFIED_FILES[@]}" | tr " " "\n" | sort | uniq -u | tr "\n" " ")" - echo "Input files: ${INPUT_FILES[*]}" - echo "Matching modified files: ${UNIQUE_ALL_MODIFIED_FILES[*]}" + OTHER_CHANGED_FILES=$(echo "${OTHER_CHANGED_FILES_ARRAY[*]}" | tr " " "\n" | sort -u | awk -v d="$INPUT_SEPARATOR" '{s=(NR==1?s:s d)$0}END{print s}') - if [[ -n "${UNIQUE_ALL_MODIFIED_FILES[*]}" ]]; then + echo "Matching modified files: ${UNIQUE_ALL_MODIFIED_FILES_ARRAY[*]}" + + if [[ -n "${UNIQUE_ALL_MODIFIED_FILES_ARRAY[*]}" ]]; then echo "::set-output name=any_changed::true" else echo "::set-output name=any_changed::false" fi - if [[ -n "${OTHER_CHANGED_FILES[*]}" ]]; then - echo "Non Matching modified files: ${OTHER_CHANGED_FILES[*]}" + if [[ -n "${OTHER_CHANGED_FILES_ARRAY[*]}" ]]; then + echo "Non Matching modified files: ${OTHER_CHANGED_FILES_ARRAY[*]}" echo "::set-output name=only_changed::false" echo "::set-output name=other_changed_files::$OTHER_CHANGED_FILES" else