-
Notifications
You must be signed in to change notification settings - Fork 1
113 lines (100 loc) · 3.23 KB
/
deploy.yml
File metadata and controls
113 lines (100 loc) · 3.23 KB
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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
name: Deploy server
on:
workflow_call:
inputs:
aws_region:
required: true
type: string
environment:
required: true
type: string
aws_role:
required: true
type: string
jobs:
build_server:
name: Build Server
permissions:
id-token: write
contents: read
packages: write
environment: ${{ inputs.environment }}
runs-on: ubuntu-24.04
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- 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: ${{ inputs.aws_region }}
role-to-assume: ${{ inputs.aws_role }}
- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Login to Amazon ECR
id: login-ecr
uses: aws-actions/amazon-ecr-login@v2
with:
mask-password: 'true'
- name: Build server
uses: docker/build-push-action@v6
with:
push: true
tags: ${{ steps.login-ecr.outputs.registry }}/tmm-bluto:${{ github.sha }}
file: ./Dockerfile
platforms: linux/amd64,linux/arm64
cache-from: type=registry,ref=ghcr.io/bluto-dev/bluto:1-buildcache
cache-to: type=registry,ref=ghcr.io/bluto-dev/bluto:1-buildcache,mode=max
deploy_server:
needs:
- build_server
name: Deploy server
permissions:
id-token: write
contents: read
packages: write
environment: ${{ inputs.environment }}
runs-on: ubuntu-24.04
steps:
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v4
with:
aws-region: ${{ inputs.aws_region }}
role-to-assume: ${{ inputs.aws_role }}
- name: Login to Amazon ECR
id: login-ecr
uses: aws-actions/amazon-ecr-login@v2
- name: Download server task definition
run: |
aws ecs describe-task-definition --task-definition tmm-bluto \
--query taskDefinition | jq -r 'del(
.taskDefinitionArn,
.requiresAttributes,
.compatibilities,
.revision,
.status,
.registeredAt,
.registeredBy
)' > server_taskdef.json
- name: Update Amazon ECS task definition for server
id: task-def-server
uses: aws-actions/amazon-ecs-render-task-definition@v1
with:
task-definition: server_taskdef.json
container-name: bluto
image: ${{ steps.login-ecr.outputs.registry }}/tmm-bluto:${{ github.sha }}
- name: Deploy Amazon ECS backend service with new server task definition
uses: aws-actions/amazon-ecs-deploy-task-definition@v2
with:
task-definition: ${{ steps.task-def-server.outputs.task-definition }}
service: tmm-bluto
cluster: tmm-cluster
wait-for-service-stability: true
force-new-deployment: true