-
Notifications
You must be signed in to change notification settings - Fork 24
179 lines (163 loc) · 7.49 KB
/
server.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
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
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
name: Server CI
env:
AWS_REGION: il-central-1
ECS_TASK_DEFINITION: server/.aws/task-definition.json
ECR_REPOSITORY: 072085314121.dkr.ecr.il-central-1.amazonaws.com/meirim-server
on:
push:
paths:
- server/**
jobs:
test:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [14.x]
services:
test_mysql:
image: mysql:5.7
env:
MYSQL_ROOT_PASSWORD: password
ports:
- 33060:3306
steps:
- uses: actions/checkout@v2
- name: use node v${{ matrix.node-version }}
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node-version }}
- name: cache node modules
uses: actions/cache@v2
with:
path: |
~/.cache
!~/.cache/exclude
**/node_modules
key: ${{ runner.OS }}-build-${{ hashFiles('**/package-lock.json') }}
restore-keys: ${{ runner.OS }}-build-${{ env.cache-name }}
${{ runner.OS }}-build-
${{ runner.OS }}-
- name: install server dependencies
working-directory: server
run: npm install
- name: create database
run: mysql --protocol=tcp --host=localhost --port=33060 --user=root --password=password -e "CREATE DATABASE test_meirim character set UTF8 collate utf8_bin; SET GLOBAL sql_mode=(SELECT REPLACE(@@sql_mode,'ONLY_FULL_GROUP_BY,',''));"
- name: test
working-directory: server
run: npm run test
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@0e613a0980cbf65ed5b322eb7a1e075d28913a83
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: ${{ secrets.AWS_DEFAULT_REGION }}
- name: Login to Amazon ECR
id: login-ecr
uses: aws-actions/amazon-ecr-login@62f4f872db3836360b72999f4b87f1ff13310f3a
- name: use node 14.x
uses: actions/setup-node@v1
with:
node-version: 14.x
- name: install server dependencies
working-directory: server
run: npm install
- uses: mr-smithers-excellent/docker-build-push@v6
id: build-image
with:
dockerfile: server/Dockerfile
image: meirim-server
registry: 072085314121.dkr.ecr.il-central-1.amazonaws.com
directory: server
tags: ${{github.sha}},${{github.ref_name}}
env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_CI_ACCESS_KEY }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_CI_SECRET_KEY }}
deploy-staging:
environment: staging
runs-on: ubuntu-latest
needs: build
steps:
- uses: actions/checkout@v2
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@0e613a0980cbf65ed5b322eb7a1e075d28913a83
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: ${{ secrets.AWS_DEFAULT_REGION }}
- name: Fill in the new image ID in the Amazon ECS task definition
id: task-def
uses: aws-actions/amazon-ecs-render-task-definition@c804dfbdd57f713b6c079302a4c01db7017a36fc
with:
task-definition: ${{ env.ECS_TASK_DEFINITION }}
container-name: ${{ vars.CONTAINER_NAME }}
image: "072085314121.dkr.ecr.il-central-1.amazonaws.com/meirim-server:${{github.sha}}"
environment-variables: |
SERVER_SESSION_SECRET=${{ secrets.SERVER_SESSION_SECRET }}
SERVER_CYPHER_SECRET=${{ secrets.SERVER_CYPHER_SECRET }}
SERVER_PAYMENT_SERVICE_MASOF_ID=${{ secrets.SERVER_PAYMENT_SERVICE_MASOF_ID }}
SERVER_PAYMENT_SERVICE_API_KEY=${{ secrets.SERVER_PAYMENT_SERVICE_API_KEY }}
SERVER_PAYMENT_SERVICE_PASS=${{ secrets.SERVER_PAYMENT_SERVICE_PASS }}
SERVER_DATABASE_HOST=${{ secrets.SERVER_DATABASE_HOST }}
SERVER_DATABASE_USER=${{ secrets.SERVER_DATABASE_USER }}
SERVER_DATABASE_PASSWORD=${{ secrets.SERVER_DATABASE_PASSWORD }}
SERVER_EMAIL_SMTP_HOST=${{ secrets.SERVER_EMAIL_SMTP_HOST }}
SERVER_EMAIL_SMTP_AUTH_USER=${{ secrets.SERVER_EMAIL_SMTP_AUTH_USER }}
SERVER_EMAIL_SMTP_AUTH_PASSWORD=${{ secrets.SERVER_EMAIL_SMTP_AUTH_PASSWORD }}
SERVER_EMAIL_SMTP_AUTH_TEMPLATE_PASS=${{ secrets.SERVER_EMAIL_SMTP_AUTH_TEMPLATE_PASS }}
SERVER_EMAIL_DIGEST_PLANS=${{ secrets.SERVER_EMAIL_DIGEST_PLANS }}
SERVER_PROXY_API_KEY=${{ secrets.SERVER_PROXY_API_KEY }}
VERSION=${{github.sha}}
- name: Deploy Amazon ECS task definition
uses: aws-actions/amazon-ecs-deploy-task-definition@df9643053eda01f169e64a0e60233aacca83799a
with:
task-definition: ${{ steps.task-def.outputs.task-definition }}
service: ${{ vars.ECS_SERVICE }}
cluster: ${{ vars.ECS_CLUSTER }}
wait-for-service-stability: true
deploy-prod:
if: github.ref == 'refs/heads/master'
environment: prod
runs-on: ubuntu-latest
needs: build
steps:
- uses: actions/checkout@v2
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@0e613a0980cbf65ed5b322eb7a1e075d28913a83
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: ${{ secrets.AWS_DEFAULT_REGION }}
- name: Fill in the new image ID in the Amazon ECS task definition
id: task-def
uses: aws-actions/amazon-ecs-render-task-definition@c804dfbdd57f713b6c079302a4c01db7017a36fc
with:
task-definition: ${{ env.ECS_TASK_DEFINITION }}
container-name: ${{ vars.CONTAINER_NAME }}
image: "072085314121.dkr.ecr.il-central-1.amazonaws.com/meirim-server:${{github.sha}}"
environment-variables: |
SERVER_SESSION_SECRET=${{ secrets.SERVER_SESSION_SECRET }}
SERVER_CYPHER_SECRET=${{ secrets.SERVER_CYPHER_SECRET }}
SERVER_PAYMENT_SERVICE_MASOF_ID=${{ secrets.SERVER_PAYMENT_SERVICE_MASOF_ID }}
SERVER_PAYMENT_SERVICE_API_KEY=${{ secrets.SERVER_PAYMENT_SERVICE_API_KEY }}
SERVER_PAYMENT_SERVICE_PASS=${{ secrets.SERVER_PAYMENT_SERVICE_PASS }}
SERVER_DATABASE_HOST=${{ secrets.SERVER_DATABASE_HOST }}
SERVER_DATABASE_USER=${{ secrets.SERVER_DATABASE_USER }}
SERVER_DATABASE_PASSWORD=${{ secrets.SERVER_DATABASE_PASSWORD }}
SERVER_EMAIL_SMTP_HOST=${{ secrets.SERVER_EMAIL_SMTP_HOST }}
SERVER_EMAIL_SMTP_AUTH_USER=${{ secrets.SERVER_EMAIL_SMTP_AUTH_USER }}
SERVER_EMAIL_SMTP_AUTH_PASSWORD=${{ secrets.SERVER_EMAIL_SMTP_AUTH_PASSWORD }}
SERVER_EMAIL_SMTP_AUTH_TEMPLATE_PASS=${{ secrets.SERVER_EMAIL_SMTP_AUTH_TEMPLATE_PASS }}
SERVER_EMAIL_DIGEST_PLANS=${{ secrets.SERVER_EMAIL_DIGEST_PLANS }}
SERVER_PROXY_API_KEY=${{ secrets.SERVER_PROXY_API_KEY }}
VERSION=${{github.sha}}
- name: Deploy Amazon ECS task definition
uses: aws-actions/amazon-ecs-deploy-task-definition@df9643053eda01f169e64a0e60233aacca83799a
with:
task-definition: ${{ steps.task-def.outputs.task-definition }}
service: ${{ vars.ECS_SERVICE }}
cluster: ${{ vars.ECS_CLUSTER }}
wait-for-service-stability: true