-
Notifications
You must be signed in to change notification settings - Fork 34
160 lines (135 loc) · 5.76 KB
/
Copy pathclient.yml
File metadata and controls
160 lines (135 loc) · 5.76 KB
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
name: Client CI
on:
push:
paths:
- client/**
jobs:
test:
runs-on: ubuntu-latest
services:
test_mysql:
image: mysql:5.7
env:
MYSQL_ROOT_PASSWORD: password
ports:
- 33060:3306
steps:
- uses: actions/checkout@v2
- name: use node v14.x
uses: actions/setup-node@v1
with:
node-version: 14.x
- 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: run migrations
env:
NODE_CONFIG: '{"database": {"connection": {"host": "localhost", "port": "33060", "user": "root", "password": "password", "database": "test_meirim"}}}'
working-directory: server
run: node node_modules/knex/bin/cli.js migrate:latest
- name: install client dependencies
working-directory: client
run: npm install
- name: build frontend
working-directory: client
run: npm run build
- name: get ethereal credentials
id: get_ethereal_credentials
run: |
response=$(curl -XPOST -d "{\"requestor\": \"meirim-test\", \"version\": \"0.0.1\"}" -H "Content-Type: application/json" https://api.nodemailer.com/user)
echo "::set-output name=user::$(echo $response | jq -r '.user')"
echo "::set-output name=pass::$(echo $response | jq -r '.pass')"
- name: serve
env:
NODE_CONFIG: '{"database": {"connection": {"host": "localhost", "port": "33060", "user": "root", "password": "password", "database": "test_meirim"}}, "email": {"templates": {"digestPlans": "d-db0b55ab042e4ba9878715acd35c1d6c"}, "options": {"host": "smtp.ethereal.email", "port": 587, "secure": false, "auth": {"user": "${{ steps.get_ethereal_credentials.outputs.user }}", "pass": "${{ steps.get_ethereal_credentials.outputs.pass }}"}}}}'
working-directory: server
run: |
npm run serve &
sleep 3
- name: e2e test
working-directory: client
run: |
$(npm bin)/cypress run --browser chrome --headless &&
$(npm bin)/cypress run --browser firefox --headless
build-and-deploy-staging:
environment: staging
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: use node v14.x
uses: actions/setup-node@v1
with:
node-version: 14.x
- name: install client dependencies
working-directory: client
run: npm install
- name: create version.txt
working-directory: client
run: echo "https://github.com/meirim-org/meirim/commit/${{ github.sha }}" > public/version.txt
- name: build
working-directory: client
run: npm run build
env:
NODE_ENV: staging
BASE_NAME: ${{ github.ref_name }}
PUBLIC_URL: "https://staging.meirim.org/${{ github.ref_name }}"
REACT_APP_BASE_API_URL: https://staging-api.meirim.org/api
- uses: jakejarvis/s3-sync-action@master
with:
args: --acl public-read --follow-symlinks --delete --cache-control max-age=3600
env:
AWS_S3_BUCKET: staging.meirim.org
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_CI_ACCESS_KEY }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_CI_SECRET_KEY }}
SOURCE_DIR: "client/build"
DEST_DIR: ${{ github.ref_name }}
AWS_REGION: il-central-1
- name: info
run: |
echo "deployed to"
echo "https://staging.meirim.org/${{ github.ref_name }}"
build-and-deploy-prod:
environment: prod
if: github.ref == 'refs/heads/master'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: use node v14.x
uses: actions/setup-node@v1
with:
node-version: 14.x
- name: install client dependencies
working-directory: client
run: npm install
- name: create version.txt
working-directory: client
run: echo "https://github.com/meirim-org/meirim/commit/${{ github.sha }}" > public/version.txt
- name: build
working-directory: client
run: npm run build
env:
PUBLIC_URL: "https://meirim.org"
NODE_ENV: production
REACT_APP_BASE_API_URL: https://api.meirim.org/api
- uses: jakejarvis/s3-sync-action@master
with:
args: --acl public-read --follow-symlinks --delete --cache-control max-age=3600
env:
AWS_S3_BUCKET: prod.meirim.org
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_CI_ACCESS_KEY }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_CI_SECRET_KEY }}
SOURCE_DIR: "client/build"
AWS_REGION: il-central-1