-
Notifications
You must be signed in to change notification settings - Fork 2
107 lines (91 loc) · 3.67 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
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
name: AWS Deployment
on:
push:
branches: [main]
env:
REGISTRY: ghcr.io # Registry for the Docker images
AWS_REGION: eu-central-1 # preferred AWS region, e.g. us-west-1
ECS_CLUSTER: default-cluster # Amazon ECS cluster name
ECS_SERVICE: chembvis # Amazon ECS service name
ECS_TASK_DEFINITION: .aws/task-definition.json # path to your Amazon ECS task definition file, e.g. .aws/task-definition.json
jobs:
aws-deployment:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- name: Checkout repository
uses: actions/checkout@v2
- name: Log in to the Container registry
uses: docker/login-action@v1
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract metadata (tags, labels) for Web
id: meta-web
uses: docker/metadata-action@v3
with:
images: ${{ env.REGISTRY }}/${{ github.repository }}_web
- name: Build and push Web image
uses: docker/build-push-action@v2
with:
context: ./client
file: ./client/deploy/prod.Dockerfile
push: true
tags: ${{ steps.meta-web.outputs.tags }}
labels: ${{ steps.meta-web.outputs.labels }}
- name: Extract metadata (tags, labels) for API-slim
id: meta-api-slim
uses: docker/metadata-action@v3
with:
images: ${{ env.REGISTRY }}/${{ github.repository }}_api_slim
- name: Build and push API-slim image
uses: docker/build-push-action@v2
with:
context: ./api
file: ./api/api.slim.Dockerfile
push: true
tags: ${{ steps.meta-api-slim.outputs.tags }}
labels: ${{ steps.meta-api-slim.outputs.labels }}
# - name: Extract metadata (tags, labels) for API
# id: meta-api
# uses: docker/metadata-action@v3
# with:
# images: ${{ env.REGISTRY }}/${{ github.repository }}_api
# - name: Build and push API image
# uses: docker/build-push-action@v2
# with:
# context: api
# push: true
# tags: ${{ steps.meta-api.outputs.tags }}
# labels: ${{ steps.meta-api.outputs.labels }}
# Deploy a new task definition in the https://docs.github.com/en/actions/deployment/deploying-to-amazon-elastic-container-service
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v1
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: ${{ env.AWS_REGION }}
- name: Render Amazon ECS task definition for Web
id: render-web-container
uses: aws-actions/amazon-ecs-render-task-definition@v1
with:
task-definition: ${{ env.ECS_TASK_DEFINITION }}
container-name: cddd-explorer-client
image: ${{ steps.meta-web.outputs.tags }}
- name: Modify Amazon ECS task definition for API
id: render-api-container
uses: aws-actions/amazon-ecs-render-task-definition@v1
with:
task-definition: ${{ steps.render-web-container.outputs.task-definition }}
container-name: cddd-explorer-api
image: ${{ steps.meta-api-slim.outputs.tags }}
- name: Deploy Amazon ECS task definition
uses: aws-actions/amazon-ecs-deploy-task-definition@v1
with:
task-definition: ${{ steps.render-api-container.outputs.task-definition }}
service: ${{ env.ECS_SERVICE }}
cluster: ${{ env.ECS_CLUSTER }}
# wait-for-service-stability: true