From b8a753edd8e761a835164cc7b84f136c7fbe51d1 Mon Sep 17 00:00:00 2001 From: Kevin Palis Date: Thu, 11 Jul 2024 13:11:54 -0400 Subject: [PATCH] Fixing branch detection. Adding error handling if branch provided is neither develop or master (#1329) --- .github/workflows/warp_release.yml | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/.github/workflows/warp_release.yml b/.github/workflows/warp_release.yml index 495c047f7b..37d1c0e3b7 100644 --- a/.github/workflows/warp_release.yml +++ b/.github/workflows/warp_release.yml @@ -1,4 +1,3 @@ - # This action releases from develop/master for all changed pipelines name: WARP Release @@ -40,16 +39,20 @@ jobs: run: | source scripts/common.sh set -e - if [[ "${GIT_BRANCH}" == "develop" ]]; then + BRANCH_NAME=$(echo "${GITHUB_REF#refs/heads/}") + if [[ "${BRANCH_NAME}" == "develop" ]]; then ENV=dev - elif [[ "${GIT_BRANCH}" == "master" ]]; then + elif [[ "${BRANCH_NAME}" == "master" ]]; then ENV=prod + else + echo "Error: Branch ${BRANCH_NAME} is not a valid release branch." + exit 1 fi echo $ENV echo "Getting all changed pipelines since last commit before releasing from develop" previous_commit_hash=$(git rev-parse HEAD^1) changed_pipelines=$(get_modified_pipelines ${previous_commit_hash}) - echo branch: ${GIT_BRANCH} previous_commit_hash: ${previous_commit_hash} env: ${ENV} + echo branch: ${BRANCH_NAME} previous_commit_hash: ${previous_commit_hash} env: ${ENV} if [[ -n ${ENV} ]]; then if [[ -n ${changed_pipelines[@]} ]]; then for pipeline in ${changed_pipelines[@]}; do @@ -62,6 +65,4 @@ jobs: echo "Releases are only made on merge to develop and master" fi env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} \ No newline at end of file