From cb2989a43993f4b39b9f5031c8be7fb05ceb2230 Mon Sep 17 00:00:00 2001 From: Douze Baie <12b@distrilab.fr> Date: Thu, 26 Sep 2024 22:26:07 +0200 Subject: [PATCH] add safeguard against running from another branch than main in push-to-prod script --- bin/push-to-prod.sh | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/bin/push-to-prod.sh b/bin/push-to-prod.sh index 3744c00..6aa8e61 100755 --- a/bin/push-to-prod.sh +++ b/bin/push-to-prod.sh @@ -1,6 +1,12 @@ -#!/bin/bash +#!/usr/bin/env bash # push main to prod (which will trigger the deploy action) -git checkout prod -git merge --ff-only main -git push origin prod -git checkout main +CURR_BRANCH=$(git symbolic-ref --short HEAD) +if [[ ${CURR_BRANCH} == "main" ]]; then + echo pushing main to prod... + git checkout prod + git merge --ff-only main + git push origin prod + git checkout main +else + echo "This script is meant to be run from the main branch!" +fi