-
Notifications
You must be signed in to change notification settings - Fork 1
80 lines (68 loc) · 2.24 KB
/
develop-deploy-chats.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
69
70
71
72
73
74
75
76
77
78
79
80
name: (Develop) Deploy Chats
on:
push:
branches:
- main
paths:
- containers/chats/**
workflow_dispatch:
permissions:
id-token: write
contents: read
env:
ECS_CLUSTER: main
ECS_SERVICE: chat
ECS_TASK_DEFINITION: chat
ECR_REPOSITORY: chat
CONTAINER_NAME: chat
jobs:
deployment:
name: Deployment
runs-on: ubuntu-latest
environment: develop
defaults:
run:
working-directory: ./containers/chats
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v4
with:
aws-region: ${{ vars.AWS_REGION }}
role-to-assume: ${{ vars.AWS_GITHUB_ROLE }}
- name: Login to Amazon ECR
id: login-ecr
uses: aws-actions/amazon-ecr-login@v2
- name: Build, tag, and push image to Amazon ECR
id: build-image
uses: docker/build-push-action@v5
with:
push: true
context: ./containers/chats
tags: |
${{ steps.login-ecr.outputs.registry }}/${{ env.ECR_REPOSITORY }}:${{ github.sha }}
${{ steps.login-ecr.outputs.registry }}/${{ env.ECR_REPOSITORY }}:latest
platforms: linux/arm64
- name: Download task definition
run: |
aws ecs describe-task-definition \
--task-definition $ECS_TASK_DEFINITION \
--query taskDefinition \
--region ${{ vars.AWS_REGION }} > ../../task-definition.json
- name: Fill in the new image ID in the Amazon ECS task definition
id: task-def
uses: aws-actions/amazon-ecs-render-task-definition@v1
with:
task-definition: task-definition.json
container-name: ${{ env.CONTAINER_NAME }}
image: ${{ steps.login-ecr.outputs.registry }}/${{ env.ECR_REPOSITORY }}:${{ github.sha }}
- name: Deploy to ECS
uses: aws-actions/amazon-ecs-deploy-task-definition@v1
with:
service: ${{ env.ECS_SERVICE }}
cluster: ${{ env.ECS_CLUSTER }}
task-definition: ${{ steps.task-def.outputs.task-definition }}
wait-for-service-stability: true