Skip to content

Commit 1456fcc

Browse files
committed
Merge branch 'main' of https://github.com/fazleyrabby/laravel-boilerplate into production
2 parents 5bd7134 + 4c83461 commit 1456fcc

File tree

1 file changed

+60
-0
lines changed

1 file changed

+60
-0
lines changed

.github/workflows/deploy.yml

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
name: Deploy Laravel to cPanel via SSH
2+
3+
on:
4+
push:
5+
branches:
6+
- production # Or your deployment branch
7+
8+
jobs:
9+
deploy:
10+
runs-on: ubuntu-latest
11+
12+
steps:
13+
- name: ⬇️ Checkout Code
14+
uses: actions/checkout@v3
15+
16+
- name: 🧰 Set up PHP
17+
uses: shivammathur/setup-php@v2
18+
with:
19+
php-version: '8.2'
20+
21+
- name: 📦 Install Dependencies
22+
run: composer install --no-dev --optimize-autoloader --ignore-platform-reqs
23+
24+
- name: 🎯 (Optional) Build Frontend
25+
run: |
26+
npm ci
27+
npm run build
28+
29+
- name: 📄 Write .env file from Secret
30+
run: echo "${{ secrets.LARABRIX_ENV }}" > .env
31+
32+
- name: 🗜️ ZIP Files
33+
run: |
34+
zip -r deploy.zip . \
35+
-x "**/node_modules/*" "**/.git*" "**/tests/*" "**/storage/logs/*" "**/vendor/composer/*"
36+
37+
- name: 🔐 Add SSH Key
38+
uses: webfactory/ssh-agent@v0.7.0
39+
with:
40+
ssh-private-key: ${{ secrets.SSH_PRIVATE_KEY }}
41+
42+
- name: 📤 Upload ZIP
43+
run: |
44+
scp -P ${{ secrets.SSH_PORT }} deploy.zip ${{ secrets.SSH_USERNAME }}@${{ secrets.SSH_HOST }}:~/deploy.zip
45+
46+
- name: ⚙️ SSH Unzip & Deploy
47+
run: |
48+
ssh -p ${{ secrets.SSH_PORT }} ${{ secrets.SSH_USERNAME }}@${{ secrets.SSH_HOST }} << 'EOF'
49+
cd /home/rhtechde/larabrix.rhtech.de
50+
unzip -o ~/deploy.zip -d ./
51+
rm ~/deploy.zip
52+
53+
php artisan migrate --force
54+
php artisan config:cache
55+
php artisan route:cache
56+
php artisan view:cache
57+
58+
chmod -R 755 storage
59+
chmod -R 755 bootstrap/cache
60+
EOF

0 commit comments

Comments
 (0)