chore: update deployment workflow to use SSH key and improve repository synchronization process

This commit is contained in:
pbao9
2026-05-12 14:35:27 +07:00
parent 2d4f0fd4b2
commit 59df3977c8
+24 -15
View File
@@ -1,4 +1,4 @@
name: Deploy Portal
name: Deploy Portal API
on:
push:
@@ -8,39 +8,48 @@ on:
jobs:
deploy:
name: Deploy to Production
runs-on: ubuntu-latest
steps:
- name: Deploy via SSH
- name: Deploy
uses: appleboy/ssh-action@v1.2.0
with:
host: ${{ secrets.HOST }}
username: ${{ secrets.USERNAME }}
password: ${{ secrets.SSH_PASSWORD }}
key: ${{ secrets.SSH_PRIVATE_KEY }}
port: ${{ secrets.PORT }}
script_stop: true
script: |
set -e
DEPLOY_PATH="/var/www/vhosts/api.portal.tgs.com.vn/httpdocs"
BRANCH="production"
REPO_URL="${{ secrets.REPO_URL }}"
if [ ! -d "$DEPLOY_PATH/.git" ]; then
echo "First deploy - cloning repository..."
git clone -b product "$REPO_URL" "$DEPLOY_PATH"
cd httpdocs
if [ ! -d ".git" ]; then
echo "First deploy..."
rm -rf ./*
git clone -b "$BRANCH" "$REPO_URL" .
else
echo "Pulling latest code..."
cd "$DEPLOY_PATH"
git pull origin product
echo "Updating source..."
git fetch origin
git reset --hard origin/$BRANCH
fi
echo "Installing dependencies..."
composer install --no-dev --optimize-autoloader --no-interaction --no-progress
composer install \
--no-dev \
--optimize-autoloader \
--no-interaction
echo "Running migrations..."
php artisan migrate --force
echo "Optimizing..."
php artisan optimize
php artisan queue:restart || true
echo "Deploy completed."