-
Notifications
You must be signed in to change notification settings - Fork 5
68 lines (58 loc) · 2.4 KB
/
deployment.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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
name: Deploy Backend Services to Amazon ECS
on:
push:
branches: [ 'main' ]
pull_request:
branches: [ 'main' ] # Temporary for testing
types: [ 'opened', 'reopened', 'synchronize' ]
env:
AWS_REGION: ap-southeast-1
ECR_REPOSITORY: question
ECS_SERVICE: question-service
ECS_CLUSTER: backend-cluster
ECS_TASK_DEFINITION: question
CONTAINER_NAME: question
permissions:
id-token: write # This is required for requesting the JWT
contents: read # This is required for actions/checkout
jobs:
deploy:
name: Deploy Question Service
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Configure AWS credentials
uses: aws-actions/[email protected]
with:
role-to-assume: arn:aws:iam::491085383176:role/github_ecs
role-session-name: GitHub_to_AWS_via_FederatedOIDC
aws-region: ${{ env.AWS_REGION }}
- name: Sts GetCallerIdentity
run: |
aws sts get-caller-identity
- name: Build, tag, and push image to Amazon ECR
id: build-image
env:
ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }}
IMAGE_TAG: latest
run: |
aws ecr get-login-password --region ap-southeast-1 | docker login --username AWS --password-stdin 491085383176.dkr.ecr.ap-southeast-1.amazonaws.com
docker build -t $ECR_REPOSITORY ./services/question
docker tag question:latest $ECR_REGISTRY/$ECR_REPOSITORY:latest
docker push docker push $ECR_REGISTRY/$ECR_REPOSITORY:latest
echo "image=$ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG" >> $GITHUB_OUTPUT
# - name: Fill in the new image ID in the Amazon ECS task definition
# id: task-def
# uses: aws-actions/amazon-ecs-render-task-definition@c804dfbdd57f713b6c079302a4c01db7017a36fc
# with:
# task-definition: ${{ env.ECS_TASK_DEFINITION }}
# container-name: ${{ env.CONTAINER_NAME }}
# image: ${{ steps.build-image.outputs.image }}
# - name: Deploy Amazon ECS task definition
# uses: aws-actions/amazon-ecs-deploy-task-definition@df9643053eda01f169e64a0e60233aacca83799a
# with:
# task-definition: ${{ steps.task-def.outputs.task-definition }}
# service: ${{ env.ECS_SERVICE }}
# cluster: ${{ env.ECS_CLUSTER }}
# wait-for-service-stability: true