-
Notifications
You must be signed in to change notification settings - Fork 1
78 lines (62 loc) · 2.24 KB
/
deploy.yml
File metadata and controls
78 lines (62 loc) · 2.24 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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
name: 🚀 Deploy Laravel App
on:
push:
branches:
- main
- staging
jobs:
web-deploy:
name: 🎉 Deploy to Server
runs-on: ubuntu-latest
steps:
# Step 1: Checkout the latest code
- name: 🚚 Get latest code
uses: actions/checkout@v3
# Step 2: Deploy to VPS using SSH
- name: 📂 Deploy via SSH
uses: appleboy/ssh-action@v1.0.3
with:
host: ${{ secrets.VPS_HOST }}
username: ${{ secrets.VPS_USER }}
key: ${{ secrets.VPS_SSH_KEY }}
port: 22
script: |
# Determine the deployment directory based on the branch
case "${{ github.ref_name }}" in
"main")
DEPLOY_DIR="/www/wwwroot/app.munasiq"
;;
"staging")
DEPLOY_DIR="/www/wwwroot/staging.munasiq"
;;
*)
echo "❌ Unknown branch: ${{ github.ref_name }}"
exit 1
;;
esac
echo "📌 Deploying branch: ${{ github.ref_name }}"
echo "📂 Target directory: $DEPLOY_DIR"
cd "$DEPLOY_DIR"
echo "🔄 Pulling latest code..."
git stash
git pull origin ${{ github.ref_name }}
echo "⚙️ Switching PHP version..."
sudo update-alternatives --set php /www/server/php/84/bin/php
echo "📦 Installing PHP dependencies..."
composer install --no-dev --prefer-dist --optimize-autoloader
echo "📦 Installing Node dependencies..."
npm install --legacy-peer-deps
echo "⚡ Building assets..."
npm run build
echo "🔧 Optimizing Filament..."
php artisan filament:optimize || true
echo "📊 Running migrations..."
php artisan migrate --force
echo "🧹 Clearing and caching configs..."
php artisan l5-swagger:generate
php artisan config:cache
php artisan route:cache
php artisan view:cache
echo "🔄 Restarting Supervisor..."
sudo systemctl restart supervisor
echo "✅ Deployment completed successfully!"