blob: 2a5a6b29417e8fc5693e9b8c5ca9e81bcbccf3be [file] [log] [blame]
#!/bin/bash
read -r -a TARGET_DIRS <<< "$*"
cat ${GITHUB_EVENT_PATH}
COMMITS=$(jq '.pull_request.commits' "${GITHUB_EVENT_PATH}")
echo "COMMITS: ${COMMITS}"
git --version
CHANGED_DIRS=$(git diff --dirstat=files,0 ${GITHUB_SHA}~${COMMITS} | awk '{ print $2 }')
echo "CHANGED_DIRS are : ${CHANGED_DIRS}"
found_changed_dir_not_in_target_dirs="no"
for changed_dir in ${CHANGED_DIRS}
do
matched="no"
for target_dir in "${TARGET_DIRS[@]}"
do
if [[ ${changed_dir} == "${target_dir}"* ]]; then
matched="yes"
break
fi
done
if [[ ${matched} == "no" ]]; then
found_changed_dir_not_in_target_dirs="yes"
break
fi
done
if [[ ${found_changed_dir_not_in_target_dirs} == "yes" ]]; then
echo "Changes ${CHANGED_DIRS} not only in $*, setting 'changed_only' to 'no'"
echo ::set-output name=changed_only::no
else
echo "Changes ${CHANGED_DIRS} only in $*, setting 'changed_only' to 'yes'"
echo ::set-output name=changed_only::yes
fi