-
Notifications
You must be signed in to change notification settings - Fork 0
113 lines (101 loc) · 3.4 KB
/
deploy.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
108
109
110
111
112
113
name: Backend Workflow
on:
pull_request:
push:
branches:
- develop
- release
jobs:
flake8_checker:
runs-on: ubuntu-latest
steps:
- name: Setup Python
uses: actions/setup-python@v1
with:
python-version: 3.8
- name: Install flake8
run: pip install flake8
- name: Run flake8
uses: suo/flake8-github-action@releases/v1
with:
checkName: 'flake8_checker' # NOTE: this needs to be the same as the job name
build-prod:
name: Build and push images
runs-on: ubuntu-latest
environment:
name: production
url: https://server.labs.thedeep.io/admin/
strategy:
matrix:
include:
- image: ./handlers/ecs/entryextraction/
ecr_repo: ENTRYEXTRACTION_REPO_NAME
- image: ./handlers/ecs/geolocations/
ecr_repo: GEOLOCATIONS_REPO_NAME
- image: ./handlers/ecs/ngrams/
ecr_repo: NGRAMS_REPO_NAME
- image: ./handlers/ecs/summarization_v2/
ecr_repo: SUMMARIZATION_V2_REPO_NAME
- image: ./handlers/ecs/textextraction/
ecr_repo: TEXTEXTRACTION_REPO_NAME
- image: ./handlers/ecs/topicmodeling/
ecr_repo: TOPICMODELING_REPO_NAME
- image: ./handlers/lambda/reliability
ecr_repo: RELIABILITY_REPO_NAME
if: github.ref == 'refs/heads/release'
steps:
- name: Checkout
uses: actions/checkout@v3
- 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: ${{ secrets.AWS_REGION }}
- name: Login to Amazon ECR
id: login-ecr
uses: aws-actions/amazon-ecr-login@v1
- name: Build, tag, and push the image to Amazon ECR
id: build-image
env:
ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }}
ECR_REPOSITORY: ${{ secrets[matrix.ecr_repo] }}
IMAGE_TAG: latest
run: |
# Build a docker container and push it to ECR
cd ${{ matrix.image }}
docker build -t $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG .
docker push $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG
terraform:
name: Terraform configurations
needs: build-prod
runs-on: ubuntu-latest
defaults:
run:
working-directory: "./"
if: github.ref == 'refs/heads/release'
steps:
- 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: ${{ secrets.AWS_REGION }}
- name: Checkout code
uses: actions/checkout@v2
- name: Setup Terraform
uses: hashicorp/setup-terraform@v1
with:
terraform_version: 1.1.2
- name: Terraform init
id: init
run: terraform init -upgrade
- name: Terraform validate
id: validate
run: terraform validate
- name: Terraform plan
id: plan
run: terraform plan -var-file=prod.tfvars -no-color
- name: Terraform apply
id: apply
run: terraform apply -var-file=prod.tfvars -auto-approve -no-color