This repository has been archived by the owner on Feb 14, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
54 lines (49 loc) · 1.94 KB
/
cd-dev-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
on:
push:
branches:
- "master"
paths:
- "api/**"
- "Cargo.lock"
- "**/cd-dev-api.yml"
- "helpers/**"
env:
SERVICE_NAME: api
REPOSITORY: ${{ secrets.AWS_ECR_REGISTRY }}
IMAGE_TAG: latest-dev
jobs:
build:
name: Build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Build Docker image
run: docker build -t $REPOSITORY/code-library-$SERVICE_NAME:$IMAGE_TAG -f $SERVICE_NAME/Dockerfile .
- name: Save Docker image
run: docker save $REPOSITORY/code-library-$SERVICE_NAME:$IMAGE_TAG -o code-library-$SERVICE_NAME-$GITHUB_SHA.tar
- uses: actions/upload-artifact@v2
with:
name: code-library-${{ env.SERVICE_NAME }}-${{ github.sha }}
path: ${{ github.workspace }}/code-library-${{ env.SERVICE_NAME }}-${{ github.sha }}.tar
if-no-files-found: error
deploy:
name: Deploy
runs-on: ubuntu-latest
needs: build
steps:
- uses: actions/download-artifact@v2
name: Download build artifact
with:
name: code-library-${{ env.SERVICE_NAME }}-${{ github.sha }}
- name: Load Docker image
run: docker load -i code-library-$SERVICE_NAME-$GITHUB_SHA.tar
- 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: eu-central-1
- name: Login to Amazon ECR
uses: aws-actions/amazon-ecr-login@v1
- name: Push Docker image
run: docker push $REPOSITORY/code-library-$SERVICE_NAME:$IMAGE_TAG