-
Notifications
You must be signed in to change notification settings - Fork 4
106 lines (92 loc) · 2.96 KB
/
build-and-deploy-image-to-production-dispatch.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
on:
workflow_dispatch:
name: Deploy to PRODUCTION
jobs:
build-and-deploy:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [14.x]
services:
plataforma-sabia-redis:
image: redis
ports:
- 6379:6379
options: >-
--health-cmd "redis-cli ping"
--health-interval 10s
--health-timeout 5s
--health-retries 5
plataforma-sabia-mysql:
image: mysql
env:
MYSQL_ROOT_PASSWORD: ''
MYSQL_ALLOW_EMPTY_PASSWORD: true
MYSQL_DATABASE: sabia_testing
ports:
- 3306:3306
options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3
steps:
- uses: actions/checkout@v1
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node-version }}
- name: Setup API and run tests
run: |
cd packages/api
cp .env.testing .env
npm install
npm run test
npm run migration:refresh -- --seed
- name: Setup WEB and run tests
run: |
cd packages/web
npm install
npm run jest:ci
- name: Run Cypress tests
uses: cypress-io/github-action@v1
env:
ACTIONS_ALLOW_UNSECURE_COMMANDS: true
CYPRESS_RECORD_KEY: ${{ secrets.CYPRESS_RECORD_KEY }}
with:
command: npm run test:e2e:run
record: true
- name: Setup QEMU
uses: docker/setup-qemu-action@v1
- name: Setup Docker Buildx
uses: docker/setup-buildx-action@v1
- name: Login to DockerHub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_PASSWORD }}
- name: Build and push ADMIN docker image
id: docker_build_admin
uses: docker/build-push-action@v2
with:
push: true
file: ./packages/admin/docker/Dockerfile
tags: plataformasabia/admin:${{ github.sha }}
- name: Build and push WEB docker image
id: docker_build_web
uses: docker/build-push-action@v2
with:
push: true
file: ./packages/web/docker/Dockerfile
tags: plataformasabia/web:${{ github.sha }}
- name: Build and push API docker image
id: docker_build_api
uses: docker/build-push-action@v2
with:
push: true
file: ./packages/api/docker/Dockerfile
tags: plataformasabia/api:${{ github.sha }}
- name: Deploy to PRODUCTION
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.DEPLOY_HOST_VPS_1 }}
username: ${{ secrets.DEPLOY_USER_VPS_1 }}
key: ${{ secrets.DEPLOY_KEY_VPS_1 }}
port: ${{ secrets.DEPLOY_PORT_VPS_1 }}
script: ./deploy-image-to-vps.sh ${{ github.sha }}