-
Notifications
You must be signed in to change notification settings - Fork 0
47 lines (39 loc) · 1.7 KB
/
deploy_production.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# Deploys to research-catalog-production
name: deploy production
on:
push:
branches:
- production
permissions:
id-token: write
contents: read
env:
AWS_DEFAULT_REGION: us-east-1
LOCAL_TAG_NAME: research-catalog:${{ github.ref_name }}-${{ github.run_number }}
ECR_URL: 946183545209.dkr.ecr.us-east-1.amazonaws.com/research-catalog:production-latest
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- name: Check out code
uses: actions/checkout@v4
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v4
with:
role-to-assume: arn:aws:iam::946183545209:role/GithubActionsDeployerRole
aws-region: us-east-1
- name: Log in to Amazon ECR
id: login-ecr
uses: aws-actions/amazon-ecr-login@v2
- name: Build and push Docker image to Amazon ECR
run: |
docker build --build-arg NEXT_PUBLIC_APP_ENV=production --tag $LOCAL_TAG_NAME .
docker tag $LOCAL_TAG_NAME $ECR_URL
# Re-tag last latest image just in case
MANIFEST=$(aws ecr batch-get-image --repository-name research-catalog --image-ids imageTag="production-latest" --output json | jq --raw-output --join-output '.images[0].imageManifest')
aws ecr batch-delete-image --repository-name research-catalog --image-ids imageTag="production-previous" || true
aws ecr put-image --repository-name research-catalog --image-tag "production-previous" --image-manifest "$MANIFEST" || true
docker push $ECR_URL
- name: Update ECS service
run: |
aws ecs update-service --cluster research-catalog-production --service research-catalog-production --force-new-deployment