Update action.yml
This commit is contained in:
parent
5c76029233
commit
e2bd4f229f
47
action.yml
47
action.yml
@ -59,7 +59,6 @@ runs:
|
|||||||
export INPUT_FILES="${{ inputs.files }}"
|
export INPUT_FILES="${{ inputs.files }}"
|
||||||
export INPUT_SEPARATOR="${{ inputs.separator }}"
|
export INPUT_SEPARATOR="${{ inputs.separator }}"
|
||||||
echo "Getting head sha..."
|
echo "Getting head sha..."
|
||||||
|
|
||||||
if [[ -z $GITHUB_BASE_REF ]]; then
|
if [[ -z $GITHUB_BASE_REF ]]; then
|
||||||
HEAD_SHA=$(git rev-parse HEAD^1 || true)
|
HEAD_SHA=$(git rev-parse HEAD^1 || true)
|
||||||
else
|
else
|
||||||
@ -67,9 +66,7 @@ runs:
|
|||||||
git fetch --depth=1 origin "${TARGET_BRANCH}":"${TARGET_BRANCH}"
|
git fetch --depth=1 origin "${TARGET_BRANCH}":"${TARGET_BRANCH}"
|
||||||
HEAD_SHA=$(git rev-parse "${TARGET_BRANCH}" || true)
|
HEAD_SHA=$(git rev-parse "${TARGET_BRANCH}" || true)
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo "Using head sha: $HEAD_SHA..."
|
echo "Using head sha: $HEAD_SHA..."
|
||||||
|
|
||||||
if [[ -z "$INPUT_FILES" ]]; then
|
if [[ -z "$INPUT_FILES" ]]; then
|
||||||
echo "Getting diff..."
|
echo "Getting diff..."
|
||||||
ADDED=$(git diff --diff-filter=A --name-only "$HEAD_SHA" | tr "\n" "$INPUT_SEPARATOR" | sed -E "s/($INPUT_SEPARATOR)$//")
|
ADDED=$(git diff --diff-filter=A --name-only "$HEAD_SHA" | tr "\n" "$INPUT_SEPARATOR" | sed -E "s/($INPUT_SEPARATOR)$//")
|
||||||
@ -93,24 +90,23 @@ runs:
|
|||||||
UNKNOWN_ARRAY=()
|
UNKNOWN_ARRAY=()
|
||||||
ALL_CHANGED_ARRAY=()
|
ALL_CHANGED_ARRAY=()
|
||||||
ALL_MODIFIED_FILES_ARRAY=()
|
ALL_MODIFIED_FILES_ARRAY=()
|
||||||
|
|
||||||
for path in ${INPUT_FILES}
|
for path in ${INPUT_FILES}
|
||||||
do
|
do
|
||||||
echo "Checking for file changes: \"${path}\"..."
|
echo "Checking for file changes: \"${path}\"..."
|
||||||
IFS=" "
|
IFS=" "
|
||||||
|
|
||||||
ADDED_ARRAY+=($(git diff --diff-filter=A --name-only "$HEAD_SHA" | grep -E "(${path})" | xargs printf "%s$INPUT_SEPARATOR" || true))
|
ADDED_ARRAY+=("$(git diff --diff-filter=A --name-only "$HEAD_SHA" | grep -E "(${path})" | xargs printf "%s$INPUT_SEPARATOR" || true)")
|
||||||
COPIED_ARRAY+=($(git diff --diff-filter=C --name-only "$HEAD_SHA" | grep -E "(${path})" | xargs printf "%s$INPUT_SEPARATOR" || true))
|
COPIED_ARRAY+=("$(git diff --diff-filter=C --name-only "$HEAD_SHA" | grep -E "(${path})" | xargs printf "%s$INPUT_SEPARATOR" || true)")
|
||||||
DELETED_ARRAY+=($(git diff --diff-filter=D --name-only "$HEAD_SHA" | grep -E "(${path})" | xargs printf "%s$INPUT_SEPARATOR" || true))
|
DELETED_ARRAY+=("$(git diff --diff-filter=D --name-only "$HEAD_SHA" | grep -E "(${path})" | xargs printf "%s$INPUT_SEPARATOR" || true)")
|
||||||
MODIFIED_ARRAY+=($(git diff --diff-filter=M --name-only "$HEAD_SHA" | grep -E "(${path})" | xargs printf "%s$INPUT_SEPARATOR" || true))
|
MODIFIED_ARRAY+=("$(git diff --diff-filter=M --name-only "$HEAD_SHA" | grep -E "(${path})" | xargs printf "%s$INPUT_SEPARATOR" || true)")
|
||||||
RENAMED_ARRAY+=($(git diff --diff-filter=R --name-only "$HEAD_SHA" | grep -E "(${path})" | xargs printf "%s$INPUT_SEPARATOR" || true))
|
RENAMED_ARRAY+=("$(git diff --diff-filter=R --name-only "$HEAD_SHA" | grep -E "(${path})" | xargs printf "%s$INPUT_SEPARATOR" || true)")
|
||||||
CHANGED_ARRAY+=($(git diff --diff-filter=T --name-only "$HEAD_SHA" | grep -E "(${path})" | xargs printf "%s$INPUT_SEPARATOR" || true))
|
CHANGED_ARRAY+=("$(git diff --diff-filter=T --name-only "$HEAD_SHA" | grep -E "(${path})" | xargs printf "%s$INPUT_SEPARATOR" || true)")
|
||||||
UNMERGED_ARRAY+=($(git diff --diff-filter=U --name-only "$HEAD_SHA" | grep -E "(${path})" | xargs printf "%s$INPUT_SEPARATOR" || true))
|
UNMERGED_ARRAY+=("$(git diff --diff-filter=U --name-only "$HEAD_SHA" | grep -E "(${path})" | xargs printf "%s$INPUT_SEPARATOR" || true)")
|
||||||
UNKNOWN_ARRAY+=($(git diff --diff-filter=X --name-only "$HEAD_SHA" | grep -E "(${path})" | xargs printf "%s$INPUT_SEPARATOR" || true))
|
UNKNOWN_ARRAY+=("$(git diff --diff-filter=X --name-only "$HEAD_SHA" | grep -E "(${path})" | xargs printf "%s$INPUT_SEPARATOR" || true)")
|
||||||
ALL_CHANGED_ARRAY+=($(git diff --diff-filter="*ACDMRTUX" --name-only "$HEAD_SHA" | grep -E "(${path})" | xargs printf "%s$INPUT_SEPARATOR" || true))
|
ALL_CHANGED_ARRAY+=("$(git diff --diff-filter="*ACDMRTUX" --name-only "$HEAD_SHA" | grep -E "(${path})" | xargs printf "%s$INPUT_SEPARATOR" || true)")
|
||||||
ALL_MODIFIED_FILES_ARRAY+=($(git diff --diff-filter="ACM" --name-only "$HEAD_SHA" | grep -E "(${path})" | xargs printf "%s$INPUT_SEPARATOR" || true))
|
ALL_MODIFIED_FILES_ARRAY+=("$(git diff --diff-filter="ACM" --name-only "$HEAD_SHA" | grep -E "(${path})" | xargs printf "%s$INPUT_SEPARATOR" || true)")
|
||||||
done
|
done
|
||||||
|
|
||||||
ADDED=$(echo "${ADDED_ARRAY[@]}" | sed -E "s/($INPUT_SEPARATOR)$//")
|
ADDED=$(echo "${ADDED_ARRAY[@]}" | sed -E "s/($INPUT_SEPARATOR)$//")
|
||||||
COPIED=$(echo "${COPIED_ARRAY[@]}" | sed -E "s/($INPUT_SEPARATOR)$//")
|
COPIED=$(echo "${COPIED_ARRAY[@]}" | sed -E "s/($INPUT_SEPARATOR)$//")
|
||||||
DELETED=$(echo "${DELETED_ARRAY[@]}" | sed -E "s/($INPUT_SEPARATOR)$//")
|
DELETED=$(echo "${DELETED_ARRAY[@]}" | sed -E "s/($INPUT_SEPARATOR)$//")
|
||||||
@ -121,9 +117,9 @@ runs:
|
|||||||
UNKNOWN=$(echo "${UNKNOWN_ARRAY[@]}" | sed -E "s/($INPUT_SEPARATOR)$//")
|
UNKNOWN=$(echo "${UNKNOWN_ARRAY[@]}" | sed -E "s/($INPUT_SEPARATOR)$//")
|
||||||
ALL_CHANGED=$(echo "${ALL_CHANGED_ARRAY[@]}" | sed -E "s/($INPUT_SEPARATOR)$//")
|
ALL_CHANGED=$(echo "${ALL_CHANGED_ARRAY[@]}" | sed -E "s/($INPUT_SEPARATOR)$//")
|
||||||
ALL_MODIFIED_FILES=$(echo "${ALL_MODIFIED_FILES_ARRAY[@]}" | sed -E "s/($INPUT_SEPARATOR)$//")
|
ALL_MODIFIED_FILES=$(echo "${ALL_MODIFIED_FILES_ARRAY[@]}" | sed -E "s/($INPUT_SEPARATOR)$//")
|
||||||
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo "Added files: $ADDED"
|
echo "Added files: $ADDED"
|
||||||
echo "Copied files: $COPIED"
|
echo "Copied files: $COPIED"
|
||||||
echo "Deleted files: $DELETED"
|
echo "Deleted files: $DELETED"
|
||||||
@ -134,20 +130,18 @@ runs:
|
|||||||
echo "Unknown files: $UNKNOWN"
|
echo "Unknown files: $UNKNOWN"
|
||||||
echo "All changed files: $ALL_CHANGED"
|
echo "All changed files: $ALL_CHANGED"
|
||||||
echo "All modified files: $ALL_MODIFIED_FILES"
|
echo "All modified files: $ALL_MODIFIED_FILES"
|
||||||
|
|
||||||
if [[ -n "$INPUT_FILES" ]]; then
|
|
||||||
OUTPUT_ALL_MODIFIED_FILES=${ALL_MODIFIED_FILES//$INPUT_SEPARATOR/ )
|
|
||||||
ALL_INPUT_FILES=${INPUT_FILES//\n/ }
|
|
||||||
|
|
||||||
|
if [[ -n "$INPUT_FILES" ]]; then
|
||||||
|
# shellcheck disable=SC2001
|
||||||
|
OUTPUT_ALL_MODIFIED_FILES=$(echo "$ALL_MODIFIED_FILES" | sed "s/$INPUT_SEPARATOR/ /g")
|
||||||
|
ALL_INPUT_FILES=${INPUT_FILES//\n/ }
|
||||||
SORTED_INPUT_FILES=()
|
SORTED_INPUT_FILES=()
|
||||||
SORTED_OUTPUT_ALL_MODIFIED_FILES=()
|
SORTED_OUTPUT_ALL_MODIFIED_FILES=()
|
||||||
|
|
||||||
IFS=" " read -r -a SORTED_INPUT_FILES <<< "$(sort <<<"${ALL_INPUT_FILES[*]}")"
|
IFS=" " read -r -a SORTED_INPUT_FILES <<< "$(sort <<<"${ALL_INPUT_FILES[*]}")"
|
||||||
IFS=" " read -r -a SORTED_OUTPUT_ALL_MODIFIED_FILES <<< "$(sort <<<"${OUTPUT_ALL_MODIFIED_FILES[*]}")"
|
IFS=" " read -r -a SORTED_OUTPUT_ALL_MODIFIED_FILES <<< "$(sort <<<"${OUTPUT_ALL_MODIFIED_FILES[*]}")"
|
||||||
|
|
||||||
if [[ ${#SORTED_OUTPUT_ALL_MODIFIED_FILES[@]} -gt 0 ]]; then
|
if [[ ${#SORTED_OUTPUT_ALL_MODIFIED_FILES[@]} -gt 0 ]]; then
|
||||||
echo "::set-output name=any_changed::true"
|
echo "::set-output name=any_changed::true"
|
||||||
|
|
||||||
if [[ "${SORTED_INPUT_FILES[*]}" == "${SORTED_OUTPUT_ALL_MODIFIED_FILES[*]}" ]]; then
|
if [[ "${SORTED_INPUT_FILES[*]}" == "${SORTED_OUTPUT_ALL_MODIFIED_FILES[*]}" ]]; then
|
||||||
echo "::set-output name=all_changed::true"
|
echo "::set-output name=all_changed::true"
|
||||||
else
|
else
|
||||||
@ -157,7 +151,6 @@ runs:
|
|||||||
echo "::set-output name=any_changed::false"
|
echo "::set-output name=any_changed::false"
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo "::set-output name=added_files::$ADDED"
|
echo "::set-output name=added_files::$ADDED"
|
||||||
echo "::set-output name=copied_files::$COPIED"
|
echo "::set-output name=copied_files::$COPIED"
|
||||||
echo "::set-output name=deleted_files::$DELETED"
|
echo "::set-output name=deleted_files::$DELETED"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user