build.sh: only deploy commits present on the main branch

This commit is contained in:
Starbeamrainbowlabs 2021-09-11 01:43:45 +01:00
parent 4a40e78dd7
commit 889ccf3acc
Signed by: sbrl
GPG key ID: 1BE5172E637709C2

View file

@ -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
# ██████ ██ ██████ ██ ██ ██ ██ ██████