From afc4e07b292ebe39d0172b06d92a88b47470715f Mon Sep 17 00:00:00 2001 From: Vanessasaurus <814322+vsoch@users.noreply.github.com> Date: Sat, 7 Jan 2023 20:25:17 -0700 Subject: [PATCH] allow if/or for second filename (#8) Signed-off-by: vsoch Signed-off-by: vsoch Co-authored-by: vsoch --- entrypoint.sh | 37 +++++++++++++++++++------------------ 1 file changed, 19 insertions(+), 18 deletions(-) diff --git a/entrypoint.sh b/entrypoint.sh index b070c88..1664ee8 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -11,27 +11,28 @@ if [[ ! -f "${INPUT_FILENAME}" ]]; then exit 1 fi -# Wget the comparison file -PARENT_SHA=$(git log --pretty=%P -n 1 ${CURRENT_SHA} | cut -d ' ' -f 1) -JOBFILE="https://raw.githubusercontent.com/${INPUT_REPO}/${PARENT_SHA}/${INPUT_FILENAME}" -TMP=$(mktemp -d) - -BASENAME=$(basename ${INPUT_FILENAME}) -wget ${JOBFILE} -O "${TMP}/${BASENAME}" -if [[ "$?" != "0" ]]; then - printf "Issue getting previous job file ${JOBFILE}\n" - exit 1 -fi - -JOBFILE="${TMP}/${BASENAME}" -if [[ ! -f "${JOBFILE}" ]]; then - printf "${JOBFILE} does not exist.\n" - exit 1 -fi - # If we are verbatim given a previous filename, use it if [ ! -z ${INPUT_PREVIOUS_FILENAME} ]; then JOBFILE="${INPUT_PREVIOUS_FILENAME}" +else + + # Wget the comparison file + PARENT_SHA=$(git log --pretty=%P -n 1 ${CURRENT_SHA} | cut -d ' ' -f 1) + JOBFILE="https://raw.githubusercontent.com/${INPUT_REPO}/${PARENT_SHA}/${INPUT_FILENAME}" + TMP=$(mktemp -d) + + BASENAME=$(basename ${INPUT_FILENAME}) + wget ${JOBFILE} -O "${TMP}/${BASENAME}" + if [[ "$?" != "0" ]]; then + printf "Issue getting previous job file ${JOBFILE}\n" + exit 1 + fi + + JOBFILE="${TMP}/${BASENAME}" + if [[ ! -f "${JOBFILE}" ]]; then + printf "${JOBFILE} does not exist.\n" + exit 1 + fi fi # Required to have slack webhook in environment