-
Notifications
You must be signed in to change notification settings - Fork 0
71 lines (71 loc) · 2.42 KB
/
api.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
name: Upload Api
on:
push:
branches:
- main
paths:
- "api/**"
- ".github/workflows/api.yml"
jobs:
deploy:
runs-on: ubuntu-latest
steps:
# checks out a copy of the repo
- uses: actions/checkout@main
with:
lfs: true
- name: Checkout lfs objects
run: git lfs checkout
- 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: us-east-1
- name: Login to Amazon ECR
id: login-ecr
uses: aws-actions/amazon-ecr-login@v1
# node yarn - cache
- name: Get yarn cache directory path
id: yarn-cache-dir-path
run: echo "::set-output name=dir::$(yarn cache dir)"
- uses: actions/cache@v2
id: yarn-cache # use this to check for `cache-hit` (`steps.yarn-cache.outputs.cache-hit != 'true'`)
with:
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn-
- name: Build api
id: build-api
run: |
cd api
yarn install
yarn run predeploy
cd -
- name: Docker
id: docker-build
uses: whoan/docker-build-with-cache-action@v5
with:
username: "${{ secrets.AWS_ACCESS_KEY_ID }}"
password: "${{ secrets.AWS_SECRET_ACCESS_KEY }}"
registry: ${{ steps.login-ecr.outputs.registry }}
image_name: rescribe-api
# change image tag to ${{ github.sha }} if you want
image_tag: latest
context: api
- 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: aws/ecs-fargate/api-task.json
container-name: api
image: ${{ steps.docker-build.outputs.FULL_IMAGE_NAME }}
- name: Deploy Amazon ECS task definition
uses: aws-actions/amazon-ecs-deploy-task-definition@v1
with:
task-definition: ${{ steps.task-def.outputs.task-definition }}
service: rescribe-api
cluster: fargate
# wait until service is stable
wait-for-service-stability: false