-
Notifications
You must be signed in to change notification settings - Fork 0
51 lines (40 loc) · 1.27 KB
/
deploy.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
name: Build & Deploy
on:
push:
branches: [main]
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Deploy NodeJS app to Vultr
uses: appleboy/ssh-action@v0.1.2
with:
host: ${{ secrets.SSH_HOST }}
key: ${{ secrets.SSH_KEY }}
username: ${{ secrets.SSH_USERNAME }}
script: |
set -e
# Navigate to the project directory
if [ -d "/root/devpulkit.in" ]; then
rm -rf /root/devpulkit.in
fi
cd /root
# Clone the repository
git clone https://github.com/pulkitxm/devpulkit.in
# Ensure Node.js and npm are available
export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"
# Install PM2 globally
npm install pm2 -g || true
# Stop if present
pm2 stop devpulkit || true
# Install dependencies
cd devpulkit.in
npm install
# Build the project
npm run build
# Restart the application using PM2
pm2 start npm --name "devpulkit" -- start
echo 'Deployment successful to Vultr'