This repository was archived by the owner on Mar 31, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
64 lines (50 loc) · 2.03 KB
/
deploy-development.yml
File metadata and controls
64 lines (50 loc) · 2.03 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
name: Development deployment
on:
workflow_run:
workflows: ['Semantic release']
types:
- completed
jobs:
deploy:
name: Deploy to the development environment
runs-on: ubuntu-20.04
strategy:
matrix:
node-version: [16.x]
steps:
- name: Checkout files
uses: actions/checkout@v3
- name: Setup PNPM
uses: pnpm/action-setup@v2
with:
version: 7
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
cache: 'pnpm'
- name: Install dependencies
run: pnpm install
- name: Build
run: pnpm run build
- name: Write SSH keys
run: |
install -m 600 -D /dev/null ~/.ssh/id_rsa
echo "${{ secrets.HOSTINGER_DEVELOPMENT_SSH_KEY }}" > ~/.ssh/id_rsa
host='${{ secrets.HOSTINGER_DEVELOPMENT_IPV4 }}'
hosts="$(dig +short "$host" | grep -v '\.$' | sed -z 's|\n|,|g')$host"
ssh-keyscan -H "$hosts" > ~/.ssh/known_hosts
- name: Upload package.json
run: rsync -r ./package.json deploy@${{ secrets.HOSTINGER_DEVELOPMENT_IPV4 }}:~/app/server
- name: Upload the installed dependencies
run: rsync -r node_modules deploy@${{ secrets.HOSTINGER_DEVELOPMENT_IPV4 }}:~/app/server
- name: Upload the build
run: rsync -r dist deploy@${{ secrets.HOSTINGER_DEVELOPMENT_IPV4 }}:~/app/server
- name: Delete old PM2 processes
run: ssh deploy@${{ secrets.HOSTINGER_DEVELOPMENT_IPV4 }} "pm2 delete all"
- name: Start API
run: ssh deploy@${{ secrets.HOSTINGER_DEVELOPMENT_IPV4 }} "cd ~/app/server && pm2 start --name "server:build" dist/shared/infra/http/index.js"
- name: Start queue
run: ssh deploy@${{ secrets.HOSTINGER_DEVELOPMENT_IPV4 }} "cd ~/app/server && pm2 start --name "queue:build" dist/shared/infra/http/queue.js"
- name: Save PM2 processes
run: ssh deploy@${{ secrets.HOSTINGER_DEVELOPMENT_IPV4 }} "pm2 save"