-
Notifications
You must be signed in to change notification settings - Fork 0
146 lines (142 loc) · 4.95 KB
/
main.yaml
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
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
name: Build and Deploy leptonite.io
on:
push:
tags:
- 'v*'
pull_request:
branches:
- main
jobs:
api:
name: API related tasks
runs-on: ubuntu-latest
env:
REGISTRY: 031036423983.dkr.ecr.eu-west-2.amazonaws.com
services:
mongodb:
image: mongo:4.4.8
ports:
- 27017:27017
env:
MONGO_INITDB_ROOT_USERNAME: admin
MONGO_INITDB_ROOT_PASSWORD: secret
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v2
with:
node-version: '12'
cache: 'npm'
- run: npm install
- run: npm run app:lint
- run: npm run app:format
- run: npm run tests:app:lint
- run: npm run tests:app:format
- run: npm run tests:app:unit:coverage
- run: npm run tests:app:persistence:coverage
- run: npm run tests:app:persistence
- run: npm run tests:app:component:coverage
- run: npm run tests:app:component
- run: npm run tests:coverage:badge
- name: Configure AWS credentials
if: ${{ github.event_name == 'push' }}
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-west-2
- id: install-aws-cli
if: ${{ github.event_name == 'push' }}
uses: unfor19/install-aws-cli-action@v1
with:
version: 2
- name: ECR login
if: ${{ github.event_name == 'push' }}
run: aws ecr get-login-password | docker login --username AWS --password-stdin $REGISTRY
- name: Export TAG value
if: ${{ github.event_name == 'push' }}
run: echo "TAG=${GITHUB_REF/refs\/tags\//}" >> $GITHUB_ENV
- name: Build and push
if: ${{ github.event_name == 'push' }}
run: |
docker build --tag $REGISTRY/bsn/reference-backend:$TAG .
docker push $REGISTRY/bsn/reference-backend:$TAG
keepers:
name: Keepers related tasks
runs-on: ubuntu-latest
defaults:
run:
working-directory: "./external/keepers"
env:
REGISTRY: 031036423983.dkr.ecr.eu-west-2.amazonaws.com
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v2
with:
node-version: '12'
cache: 'npm'
- run: npm install
- name: Configure AWS credentials
if: ${{ github.event_name == 'push' }}
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-west-2
- id: install-aws-cli
if: ${{ github.event_name == 'push' }}
uses: unfor19/install-aws-cli-action@v1
with:
version: 2
- name: ECR login
if: ${{ github.event_name == 'push' }}
run: aws ecr get-login-password | docker login --username AWS --password-stdin $REGISTRY
- name: Export TAG value
if: ${{ github.event_name == 'push' }}
run: echo "TAG=${GITHUB_REF/refs\/tags\//}" >> $GITHUB_ENV
- name: Build and push
if: ${{ github.event_name == 'push' }}
run: |
docker build --tag $REGISTRY/bsn/keepers:$TAG .
docker push $REGISTRY/bsn/keepers:$TAG
triggers:
name: Triggers related tasks
runs-on: ubuntu-latest
needs: [api, keepers]
defaults:
run:
working-directory: "./terraform/functions"
steps:
- uses: actions/checkout@v2
- 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-west-2
- name: Setup Terraform
uses: hashicorp/setup-terraform@v1
with:
terraform_wrapper: false
- name: Terraform Format
id: fmt
run: terraform fmt -check -recursive
- name: Terraform Init
id: init
run: terraform init -backend-config=$TF_BACKEND_BUCKET -backend-config=$TF_BACKEND_STATE_KEY -backend-config='region=eu-west-2' -backend-config='encrypt=true'
env:
TF_BACKEND_BUCKET: ${{ secrets.TF_BACKEND_BUCKET }}
TF_BACKEND_STATE_KEY: ${{ secrets.TF_BACKEND_STATE_KEY }}
- name: Terraform Validate
id: validate
run: terraform validate -no-color
- run: 'echo "$TFVARS" > terraform.tfvars'
shell: bash
env:
TFVARS: ${{ secrets.TFVARS }}
- name: Terraform Plan
id: plan
run: terraform plan -no-color
- name: Terraform Apply
if: ${{ github.event_name == 'push' }}
id: apply
run: terraform apply -auto-approve