-
Notifications
You must be signed in to change notification settings - Fork 8
49 lines (42 loc) · 1.32 KB
/
Copy pathdeploy.yml
File metadata and controls
49 lines (42 loc) · 1.32 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
# Deploy workflow for Sparked Next Application
# This workflow automatically deploys the application to production when changes are pushed to main branch
#
# Workflow steps:
# 1. Checks out the code
# 2. Sets up Node.js environment
# 3. Installs dependencies
# 4. Builds the application
# 5. Deploys to production server using PM2 when we create a release
name: Deploy App
on:
release:
types: [published]
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- name: Checkout Code
uses: actions/checkout@v6
- name: Set up Node.js
uses: actions/setup-node@v6
with:
node-version: '22.14.0'
- name: Deploy with PM2
env:
SERVER_PASSWORD: ${{ secrets.SERVER_PASSWORD }}
run: |
sshpass -p "$SERVER_PASSWORD" ssh -o StrictHostKeyChecking=no root@95.111.229.11 << 'EOF'
cd /var/www/sparked-next
git pull origin main
corepack enable
corepack prepare pnpm@9.15.4 --activate
pnpm install --frozen-lockfile
pnpm build
if pm2 list | grep -q sparked-next; then
pm2 restart sparked-next
else
pm2 start pnpm --name sparked-next -- start
fi
pm2 save
echo "Deployment completed successfully!"
EOF