-
Notifications
You must be signed in to change notification settings - Fork 15
49 lines (39 loc) · 1.12 KB
/
deploy-to-vps.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
name: Build & deploy in VPS
name: test build
on:
push:
branches:
- main
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Use Node.js 20
uses: actions/setup-node@v3
with:
node-version: "20"
- name: Install dependencies
run: yarn install
- name: Build
run: yarn run build
deploy:
runs-on: ubuntu-latest
needs: build
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Deploy using SSH
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.HOST }}
username: ${{ secrets.USERNAME }}
key: ${{ secrets.PRIVATE_KEY }}
port: 22
script: |
cd ~/website
git pull origin main || { echo "Failed to pull latest changes from Git repository"; exit 1; }
yarn install || { echo "Failed to install dependencies"; exit 1; }
yarn run build || { echo "Build failed"; exit 1; }
pm2 restart kuosc || { echo "Failed to restart PM2"; exit 1; }