-
Notifications
You must be signed in to change notification settings - Fork 3
49 lines (39 loc) · 1.25 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
name: Node.js Deploy with SSH
on:
push:
branches:
- dev
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Set up Node.js
uses: actions/setup-node@v3
with:
node-version: '18'
- name: Install dependencies
run: npm install
- name: Deploy via SSH
uses: appleboy/ssh-action@v1.0.0
with:
host: ${{ secrets.SERVER_HOST }}
username: ${{ secrets.SERVER_USERNAME }}
password: ${{ secrets.SERVER_SSH_PASS }}
port: ${{ secrets.SERVER_SSH_PORT }} # Specify your SSH port if it's not the default (22)
script: |
export NVM_DIR=~/.nvm
source ~/.nvm/nvm.sh
npm --help
# SSH into the server
cd studentcomp
# Stop previous application if running
pm2 stop studentcompaniongui || true
# Pull the latest changes
git checkout dev
git pull origin dev
# Install or update dependencies
npm install
# Start the Node.js application with a process manager like PM2
pm2 start "npm run dev" --name studentcompaniongui