-
-
Notifications
You must be signed in to change notification settings - Fork 49
64 lines (58 loc) · 1.99 KB
/
main.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
name: Deploy API
on:
push:
branches: [main]
workflow_dispatch:
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Install SSH Key
uses: shimataro/ssh-key-action@v2
with:
key: ${{ secrets.SSH_PRIVATE_KEY }}
known_hosts: 'just-a-placeholder'
- name: Adding Known Hosts
run: ssh-keyscan -H ${{ secrets.REMOTE_SERVER_ADDRESS }} >> ~/.ssh/known_hosts
- uses: actions/checkout@v2
- name: Build API
run: |
npm install
npm run after:install
npm run build api --configuration=production
- name: Create Sentry release
uses: getsentry/action-release@v1
env:
SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }}
SENTRY_ORG: ${{ secrets.SENTRY_ORG }}
SENTRY_PROJECT: ${{ secrets.SENTRY_PROJECT }}
with:
environment: PRODUCTION
sourcemaps: './dist/app/api'
- name: Zip artifacts
run: |
tar -czvf build.tar.gz dist/ prisma/ package*
- name: Send artifacts to remote
env:
REMOTE_SERVER_USER: ${{ secrets.REMOTE_SERVER_USER }}
REMOTE_SERVER_ADDRESS: ${{ secrets.REMOTE_SERVER_ADDRESS }}
run: |
rsync -azIv ./build.tar.gz $REMOTE_SERVER_USER@$REMOTE_SERVER_ADDRESS:/home/$REMOTE_SERVER_USER/compito/build.tar.gz
- name: Start API
uses: appleboy/ssh-action@master
env:
REMOTE_SERVER_USER: ${{ secrets.REMOTE_SERVER_USER }}
with:
host: ${{ secrets.REMOTE_SERVER_ADDRESS }}
username: ${{ secrets.REMOTE_SERVER_USER }}
key: ${{ secrets.SSH_PRIVATE_KEY }}
envs: REMOTE_SERVER_USER
script: |
cd /home/$REMOTE_SERVER_USER/compito
tar -xzvf build.tar.gz
npm install
npx prisma migrate deploy
npx prisma generate
pm2 stop compito
pm2 start dist/apps/api/main.js --name compito
rm -rf build.tar.gz