Skip to content

Commit

Permalink
Create release.yml
Browse files Browse the repository at this point in the history
  • Loading branch information
zsimjee authored May 17, 2022
1 parent f53000d commit 3858af8
Showing 1 changed file with 35 additions and 0 deletions.
35 changes: 35 additions & 0 deletions release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
version: 0.2
phases:
build:
commands:
- docker login -u AWS -p $(aws ecr get-login-password --region $AWS_REGION) $ECR_ENDPOINT
- docker pull $ECR_IMAGE_URL:$PREVIOUS_STAGE_NAME
- docker tag $ECR_IMAGE_URL:$PREVIOUS_STAGE_NAME $ECR_IMAGE_URL:$STAGE_NAME
- docker push $ECR_IMAGE_URL:$STAGE_NAME
- |
if [ ! -z "$REGIONAL_ECR_ENDPOINT" -a ! -z "$REGIONAL_ECR_IMAGE_URL" ];
then
docker login -u AWS -p $(aws ecr get-login-password --region $STAGE_REGION) $REGIONAL_ECR_ENDPOINT
docker tag $ECR_IMAGE_URL:$PREVIOUS_STAGE_NAME $REGIONAL_ECR_IMAGE_URL:$STAGE_NAME
docker push $REGIONAL_ECR_IMAGE_URL:$STAGE_NAME
fi
post_build:
on-failure: CONTINUE
commands:
- region="${STAGE_REGION:-$AWS_REGION}"
- |
if [ ! -z "$LAMBDA_FUNCTION_NAME" -a "$LAMBDA_FUNCTION_NAME" != "placeholder" ];
then
imageUrl="${REGIONAL_ECR_IMAGE_URL:-$ECR_IMAGE_URL}"
aws lambda update-function-code --function-name "$LAMBDA_FUNCTION_NAME" --image-uri "$imageUrl:$STAGE_NAME" --region $region
imageSha=$(docker images --no-trunc --quiet $imageUrl:$PREVIOUS_STAGE_NAME);
aws lambda tag-resource --resource "$LAMBDA_FUNCTION_ARN" --tags "IMAGE_SHA=$imageSha" --region $region
else
echo 'Not a serverless stage'
if [ -z "$SERVICE_NAME" ] || [ "$SERVICE_NAME" == "placeholder" ];
then
echo 'Service is not ready yet. Repository tagged correctly, exiting now';
else
aws ecs update-service --service $SERVICE_NAME --cluster $CLUSTER_ARN --region $region --force-new-deployment;
fi
fi

0 comments on commit 3858af8

Please sign in to comment.