Skip to content

Commit a328c37

Browse files
author
Brett Richter
committed
update gha for when we deploy and merge qa and production
1 parent 47fa04b commit a328c37

File tree

2 files changed

+108
-0
lines changed

2 files changed

+108
-0
lines changed
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
# On merge into the development` branch, build the image and deploy to ECR.
2+
# This is on `nypl` account.
3+
name: Publish production
4+
on:
5+
push:
6+
branches:
7+
- production
8+
env:
9+
AWS_REGION: us-east-1
10+
ECR_REPOSITORY: iiif
11+
ECS_SERVICE: iiif-production
12+
ECS_CLUSTER: iiif-production
13+
IMAGE_TAG: production-latest
14+
ENVIRONMENT: production
15+
permissions:
16+
id-token: write
17+
contents: read
18+
19+
jobs:
20+
publish_production:
21+
name: Publish image to ECR and update ECS stack
22+
runs-on: ubuntu-latest
23+
steps:
24+
- name: checkout
25+
uses: actions/checkout@v3
26+
27+
- name: Configure AWS credentials
28+
uses: aws-actions/configure-aws-credentials@v2
29+
with:
30+
role-to-assume: arn:aws:iam::463786892988:role/GithubActionsDeployerRole
31+
aws-region: ${{ env.AWS_REGION }}
32+
33+
- name: Login to Amazon ECR
34+
id: login-ecr
35+
uses: aws-actions/amazon-ecr-login@v1
36+
37+
- name: Build, tag, and push image to Amazon ECR
38+
env:
39+
ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }}
40+
run: |
41+
# Build a docker container and
42+
# push it to ECR so that it can
43+
# be deployed to ECS.
44+
docker build -t $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG .
45+
docker push $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG
46+
echo "image=$ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG" >> $GITHUB_OUTPUT
47+
48+
- name: Force ECS Update
49+
# In addition to the current live version, the Global Header also
50+
# deploys to a "previous" cluster. This is just in case the new
51+
# version fails and teams require a working URL of the previous
52+
# working version.
53+
run: |
54+
aws ecs update-service --cluster $ECS_CLUSTER --service $ECS_SERVICE --force-new-deployment
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
# On merge into the development` branch, build the image and deploy to ECR.
2+
# This is on `nypl-dev` account.
3+
name: Publish qa
4+
on:
5+
push:
6+
branches:
7+
- qa
8+
env:
9+
AWS_REGION: us-east-1
10+
ECR_REPOSITORY: iiif
11+
ECS_SERVICE: iiif-qa
12+
ECS_CLUSTER: iiif-qa
13+
IMAGE_TAG: qa-latest
14+
ENVIRONMENT: qa
15+
permissions:
16+
id-token: write
17+
contents: read
18+
19+
jobs:
20+
publish_qa:
21+
name: Publish image to ECR and update ECS stack
22+
runs-on: ubuntu-latest
23+
steps:
24+
- name: checkout
25+
uses: actions/checkout@v3
26+
27+
- name: Configure AWS credentials
28+
uses: aws-actions/configure-aws-credentials@v2
29+
with:
30+
role-to-assume: arn:aws:iam::491147561046:role/GithubActionsDeployerRole
31+
aws-region: ${{ env.AWS_REGION }}
32+
33+
- name: Login to Amazon ECR
34+
id: login-ecr
35+
uses: aws-actions/amazon-ecr-login@v1
36+
37+
- name: Build, tag, and push image to Amazon ECR
38+
env:
39+
ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }}
40+
run: |
41+
# Build a docker container and
42+
# push it to ECR so that it can
43+
# be deployed to ECS.
44+
docker build -t $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG .
45+
docker push $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG
46+
echo "image=$ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG" >> $GITHUB_OUTPUT
47+
48+
- name: Force ECS Update
49+
# In addition to the current live version, the Global Header also
50+
# deploys to a "previous" cluster. This is just in case the new
51+
# version fails and teams require a working URL of the previous
52+
# working version.
53+
run: |
54+
aws ecs update-service --cluster $ECS_CLUSTER --service $ECS_SERVICE --force-new-deployment

0 commit comments

Comments
 (0)