diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index c32e86f5..0eb93305 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -108,6 +108,25 @@ jobs: echo "${{ toJSON(steps.changed-files-specific.outputs) }}" shell: bash + - name: Run changed-files with specific files comma check duplicates + id: changed-files-specific-duplicate-output + uses: ./ + with: + files: | + entrypoint.sh + *.sh + - name: Verify all_changed_files files has no duplicates + if: contains(steps.changed-files-specific-duplicate-output.outputs.all_modified_files, 'entrypoint.sh') + run: | + ALL_CHANGED_FILES=(${{ steps.changed-files-specific-duplicate-output.outputs.all_modified_files }}) + UNIQUE_ALL_CHANGED_FILES=$(echo "$ALL_CHANGED_FILES" | tr ' ' '\n' | sort -u | xargs) + + if [[ "$ALL_CHANGED_FILES[@]" != "$UNIQUE_ALL_CHANGED_FILES[@]" ]]; then + echo "Duplicate output: Expected "$UNIQUE_ALL_CHANGED_FILES" got $ALL_CHANGED_FILES" + exit 1 + fi + shell: + bash - name: Run changed-files with specific files comma separator id: changed-files-specific-comma uses: ./ diff --git a/entrypoint.sh b/entrypoint.sh index 1b3a56cd..4e1d6bcf 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -104,25 +104,25 @@ else done # shellcheck disable=SC2001 - ADDED=$(echo "${ADDED_ARRAY[*]}" | sed 's/ */'"$INPUT_SEPARATOR"'/g') + ADDED=$(echo "${ADDED_ARRAY[*]}" | sed 's/ */'"$INPUT_SEPARATOR"'/g' | tr ' ' '\n' | sort -u | xargs) # shellcheck disable=SC2001 - COPIED=$(echo "${COPIED_ARRAY[*]}" | sed 's/ */'"$INPUT_SEPARATOR"'/g') + COPIED=$(echo "${COPIED_ARRAY[*]}" | sed 's/ */'"$INPUT_SEPARATOR"'/g' | tr ' ' '\n' | sort -u | xargs) # shellcheck disable=SC2001 - DELETED=$(echo "${DELETED_ARRAY[*]}" | sed 's/ */'"$INPUT_SEPARATOR"'/g') + DELETED=$(echo "${DELETED_ARRAY[*]}" | sed 's/ */'"$INPUT_SEPARATOR"'/g' | tr ' ' '\n' | sort -u | xargs) # shellcheck disable=SC2001 - MODIFIED=$(echo "${MODIFIED_ARRAY[*]}" | sed 's/ */'"$INPUT_SEPARATOR"'/g') + MODIFIED=$(echo "${MODIFIED_ARRAY[*]}" | sed 's/ */'"$INPUT_SEPARATOR"'/g' | tr ' ' '\n' | sort -u | xargs) # shellcheck disable=SC2001 - RENAMED=$(echo "${RENAMED_ARRAY[*]}" | sed 's/ */'"$INPUT_SEPARATOR"'/g') + RENAMED=$(echo "${RENAMED_ARRAY[*]}" | sed 's/ */'"$INPUT_SEPARATOR"'/g' | tr ' ' '\n' | sort -u | xargs) # shellcheck disable=SC2001 - TYPE_CHANGED=$(echo "${TYPE_CHANGED_ARRAY[*]}" | sed 's/ */'"$INPUT_SEPARATOR"'/g') + TYPE_CHANGED=$(echo "${TYPE_CHANGED_ARRAY[*]}" | sed 's/ */'"$INPUT_SEPARATOR"'/g' | tr ' ' '\n' | sort -u | xargs) # shellcheck disable=SC2001 - UNMERGED=$(echo "${UNMERGED_ARRAY[*]}" | sed 's/ */'"$INPUT_SEPARATOR"'/g') + UNMERGED=$(echo "${UNMERGED_ARRAY[*]}" | sed 's/ */'"$INPUT_SEPARATOR"'/g' | tr ' ' '\n' | sort -u | xargs) # shellcheck disable=SC2001 - UNKNOWN=$(echo "${UNKNOWN_ARRAY[*]}" | sed 's/ */'"$INPUT_SEPARATOR"'/g') + UNKNOWN=$(echo "${UNKNOWN_ARRAY[*]}" | sed 's/ */'"$INPUT_SEPARATOR"'/g' | tr ' ' '\n' | sort -u | xargs) # shellcheck disable=SC2001 - ALL_CHANGED=$(echo "${ALL_CHANGED_ARRAY[*]}" | sed 's/ */'"$INPUT_SEPARATOR"'/g') + ALL_CHANGED=$(echo "${ALL_CHANGED_ARRAY[*]}" | sed 's/ */'"$INPUT_SEPARATOR"'/g' | tr ' ' '\n' | sort -u | xargs) # shellcheck disable=SC2001 - ALL_MODIFIED_FILES=$(echo "${ALL_MODIFIED_FILES_ARRAY[*]}" | sed 's/ */'"$INPUT_SEPARATOR"'/g') + ALL_MODIFIED_FILES=$(echo "${ALL_MODIFIED_FILES_ARRAY[*]}" | sed 's/ */'"$INPUT_SEPARATOR"'/g' | tr ' ' '\n' | sort -u | xargs) fi echo "Added files: $ADDED"