From 889ccf3accdcd16afb9b3676857ca37e93b38b52 Mon Sep 17 00:00:00 2001 From: Starbeamrainbowlabs Date: Sat, 11 Sep 2021 01:43:45 +0100 Subject: [PATCH] build.sh: only deploy commits present on the main branch --- build.sh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/build.sh b/build.sh index c92e7a9..17809ff 100755 --- a/build.sh +++ b/build.sh @@ -1,11 +1,11 @@ #!/usr/bin/env bash set -e; -current_branch="$(git rev-parse --abbrev-ref HEAD)"; +# current_branch="$(git rev-parse --abbrev-ref HEAD)"; +is_main="$(git branch --contains HEAD | awk '/HEAD/ { next } /main/ { print $1 }')"; -if [[ "${1}" == "ci" ]] && [[ "${current_branch}" != "main" ]]; then - echo "Skipping build, because we are currently on the branch '${current_branch}', and we only deploy on the 'main' branch."; - exit 0; +if [[ "${1}" == "ci" ]] && [[ ! -z "${is_main}" ]]; then + echo "Skipping build, because this commit does not appear to be on the 'main' branch, and we only deploy commits on the 'main' branch."; fi # ██████ ██ ██████ ██ ██ ██ ██ ██████