From ef1134dca7db98126adfe9ad0a47dde38e56c6af Mon Sep 17 00:00:00 2001 From: Tonye Jack Date: Sat, 24 Sep 2022 19:33:05 -0600 Subject: [PATCH] update to handle the default event.before --- diff-sha.sh | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/diff-sha.sh b/diff-sha.sh index 22697493..988c598a 100644 --- a/diff-sha.sh +++ b/diff-sha.sh @@ -62,6 +62,14 @@ if [[ -z $GITHUB_BASE_REF ]]; then if [[ -z $INPUT_BASE_SHA ]]; then PREVIOUS_SHA=$GITHUB_EVENT_BEFORE + + if [[ -z "$PREVIOUS_SHA" || "$PREVIOUS_SHA" == "0000000000000000000000000000000000000000" ]]; then + PREVIOUS_SHA=$(git rev-parse "$(git branch -r --sort=-committerdate | head -1)") + fi + if [[ "$INPUT_SHA" == "$PREVIOUS_SHA" ]]; then + PREVIOUS_SHA=$(git rev-parse "$INPUT_SHA^1") + fi + if [[ "$PREVIOUS_SHA" == "$CURRENT_SHA" ]]; then INITIAL_COMMIT="true" echo "::debug::Initial commit detected"