-
Notifications
You must be signed in to change notification settings - Fork 20
76 lines (65 loc) · 2.42 KB
/
cd.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
name: CD
on:
push:
branches: [main]
jobs:
publish:
concurrency: fname-registry-publish
timeout-minutes: 30
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
# Build image with Depot and push it to AWS ECR
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v4
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
mask-aws-account-id: no
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: us-east-1
- name: Login to AWS ECR
id: login-ecr
uses: aws-actions/amazon-ecr-login@v2
- name: Generate Docker image tag for fname-registry
id: image-tag
env:
ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }}
ECR_REPOSITORY: farcasterxyz/fname-registry
IMAGE_TAG: ${{ github.sha }}
run: echo "::set-output name=image-tag::$ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG"
shell: bash
- uses: depot/setup-action@v1
- uses: depot/build-push-action@v1
with:
buildx-fallback: true
project: ${{ secrets.DEPOT_PROJECT_ID }}
token: ${{ secrets.DEPOT_TOKEN }}
context: .
file: ./Dockerfile
platforms: "linux/arm64"
tags: ${{ steps.image-tag.outputs.image-tag }}
github-token: ${{ secrets.github_token }}
push: true
- name: Log out of Amazon ECR
if: always()
run: docker logout ${{ steps.login-ecr.outputs.registry }}
shell: bash
# Deploy the image to ECS one hub at a time to minimize overall downtime
- name: Generate release ID
id: release
run: echo "::set-output name=release::$(date +'%Y-%m-%d-%H-%M')-$(git rev-parse --short HEAD)"
shell: bash
- name: Update task-definition
id: task-def
uses: aws-actions/amazon-ecs-render-task-definition@v1
with:
task-definition: .aws/fname-registry-api.json
container-name: fname-registry-api
image: ${{ steps.image-tag.outputs.image-tag }}
- name: Push task-definition to Amazon ECS
uses: aws-actions/amazon-ecs-deploy-task-definition@v2
with:
task-definition: ${{ steps.task-def.outputs.task-definition }}
service: fname-registry-api
cluster: fname-registry-cluster
wait-for-service-stability: true