47 lines
1.5 KiB
YAML
47 lines
1.5 KiB
YAML
name: Deploy Portal
|
|
|
|
on:
|
|
push:
|
|
branches:
|
|
- production
|
|
workflow_dispatch:
|
|
|
|
jobs:
|
|
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 }}
|
|
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 }}"
|
|
|
|
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 "Running migrations..."
|
|
php artisan migrate --force
|
|
|
|
echo "Optimizing..."
|
|
php artisan optimize
|
|
|
|
echo "Deploy completed."
|