This commit is contained in:
pbao9
2026-05-12 13:50:53 +07:00
parent 96778e7bed
commit 2d4f0fd4b2
6 changed files with 150 additions and 84 deletions
+35 -28
View File
@@ -1,39 +1,46 @@
name: Deploy Portal
on:
push:
branches:
- main
workflow_dispatch:
push:
branches:
- production
workflow_dispatch:
jobs:
deploy:
name: Deploy to Production
runs-on: ubuntu-latest
deploy:
name: Deploy to Production
runs-on: ubuntu-latest
steps:
- name: Deploy via SSH
uses: appleboy/ssh-action@v1.2.0
with:
host: ${{ secrets.HOST }}
username: ${{ secrets.USERNAME }}
key: ${{ secrets.SSH_KEY }}
port: ${{ secrets.PORT }}
script_stop: true
script: |
set -e
cd ${{ secrets.PROJECT_PATH }}
steps:
- name: Deploy via SSH
uses: appleboy/ssh-action@v1.2.0
with:
host: ${{ secrets.HOST }}
username: ${{ secrets.USERNAME }}
password: ${{ secrets.SSH_PASSWORD }}
port: ${{ secrets.PORT }}
script_stop: true
script: |
set -e
DEPLOY_PATH="/var/www/vhosts/api.portal.tgs.com.vn/httpdocs"
REPO_URL="${{ secrets.REPO_URL }}"
echo "Pulling latest code..."
git pull origin main
if [ ! -d "$DEPLOY_PATH/.git" ]; then
echo "First deploy - cloning repository..."
git clone -b product "$REPO_URL" "$DEPLOY_PATH"
else
echo "Pulling latest code..."
cd "$DEPLOY_PATH"
git pull origin product
fi
echo "Installing dependencies..."
composer install --no-dev --optimize-autoloader --no-interaction --no-progress
echo "Installing dependencies..."
composer install --no-dev --optimize-autoloader --no-interaction --no-progress
echo "Running migrations..."
php artisan migrate --force
echo "Running migrations..."
php artisan migrate --force
echo "Optimizing..."
php artisan optimize
echo "Optimizing..."
php artisan optimize
echo "Deploy completed."
echo "Deploy completed."