From 3484068ed93888bd8cf59a456ea09bc3b144245c Mon Sep 17 00:00:00 2001 From: Bill Randall Date: Fri, 26 Apr 2024 16:12:00 -0400 Subject: [PATCH] Put the command in the if statement in order to handle the not found case. --- entrypoint.sh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/entrypoint.sh b/entrypoint.sh index 192a4cf8..550dba72 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -53,14 +53,14 @@ case $AMPLIFY_COMMAND in deploy) echo "deploying" - branch_exists=$(sh -c "aws amplify get-branch --app-id=${AmplifyAppId} --branch-name=$BRANCH_NAME --region=${AWS_REGION}") - if [[ -z "$branch_exists" ]]; then - echo "branch_exists is empty" + if [[ -z $(aws amplify get-branch --app-id=${AmplifyAppId} --branch-name=$BRANCH_NAME --region=${AWS_REGION} 2> /dev/null) ]]; then + echo "Creating the Amplify branch" sh -c "aws amplify create-branch --app-id=${AmplifyAppId} --branch-name=$BRANCH_NAME \ ${backend_env_arg} ${environment_variables_arg} --region=${AWS_REGION}" - sleep 10 + else + echo "branch exists, not creating it again" fi echo "starting job"