Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create buillspec to deploy code to production #5978

Merged
merged 1 commit into from
Oct 17, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions buildspec/deploy-prod.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
version: 0.2

phases:
pre_build:
commands:
- echo Logging in to Amazon ECR...
- aws --version
- aws ecr get-login-password --region eu-west-1 | docker login --username AWS --password-stdin 636146736465.dkr.ecr.eu-west-1.amazonaws.com
- export manifest=$(aws ecr batch-get-image --repository-name sfc-backend-build-images --image-ids imageTag=preprod --output text --query 'images[].imageManifest')

build:
commands:
- COMMIT_HASH=$(aws ecr describe-images --repository-name sfc-backend-build-images --image-ids imageTag=preprod --output text | awk '{print $2}' | tail -n1)
- echo Retagging the latest ecr image...
- aws ecr batch-delete-image --repository-name sfc-backend-build-images --image-ids imageTag=prod
- aws ecr put-image --repository-name sfc-backend-build-images --image-tag prod --image-manifest "$manifest"
- echo Copy s3 bucket from bnd to staging...
- aws s3 cp --recursive s3://sfc-frontend-build-artifacts/$COMMIT_HASH s3://sfc-frontend-prod/
- export $(printf "AWS_ACCESS_KEY_ID=%s AWS_SECRET_ACCESS_KEY=%s AWS_SESSION_TOKEN=%s" $(aws sts assume-role --role-arn arn:aws:iam::008366934221:role/CodebuildApprunnerCrossAccountAccessRole --role-session-name MySessionName --query "Credentials.[AccessKeyId,SecretAccessKey,SessionToken]" --output text))
- aws apprunner start-deployment --service-arn arn:aws:apprunner:eu-west-1:008366934221:service/sfc-app-runner-prod/52469c58deb84143ab8404f7ca69ccb6
Loading