chore: update deployment workflow to use SSH key and improve repository synchronization process
This commit is contained in:
@@ -1,4 +1,4 @@
|
|||||||
name: Deploy Portal
|
name: Deploy Portal API
|
||||||
|
|
||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
@@ -8,39 +8,48 @@ on:
|
|||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
deploy:
|
deploy:
|
||||||
name: Deploy to Production
|
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Deploy via SSH
|
- name: Deploy
|
||||||
uses: appleboy/ssh-action@v1.2.0
|
uses: appleboy/ssh-action@v1.2.0
|
||||||
with:
|
with:
|
||||||
host: ${{ secrets.HOST }}
|
host: ${{ secrets.HOST }}
|
||||||
username: ${{ secrets.USERNAME }}
|
username: ${{ secrets.USERNAME }}
|
||||||
password: ${{ secrets.SSH_PASSWORD }}
|
key: ${{ secrets.SSH_PRIVATE_KEY }}
|
||||||
port: ${{ secrets.PORT }}
|
port: ${{ secrets.PORT }}
|
||||||
script_stop: true
|
script_stop: true
|
||||||
script: |
|
script: |
|
||||||
set -e
|
set -e
|
||||||
DEPLOY_PATH="/var/www/vhosts/api.portal.tgs.com.vn/httpdocs"
|
|
||||||
|
BRANCH="production"
|
||||||
REPO_URL="${{ secrets.REPO_URL }}"
|
REPO_URL="${{ secrets.REPO_URL }}"
|
||||||
|
|
||||||
if [ ! -d "$DEPLOY_PATH/.git" ]; then
|
cd httpdocs
|
||||||
echo "First deploy - cloning repository..."
|
|
||||||
git clone -b product "$REPO_URL" "$DEPLOY_PATH"
|
if [ ! -d ".git" ]; then
|
||||||
|
echo "First deploy..."
|
||||||
|
|
||||||
|
rm -rf ./*
|
||||||
|
|
||||||
|
git clone -b "$BRANCH" "$REPO_URL" .
|
||||||
else
|
else
|
||||||
echo "Pulling latest code..."
|
echo "Updating source..."
|
||||||
cd "$DEPLOY_PATH"
|
|
||||||
git pull origin product
|
git fetch origin
|
||||||
|
|
||||||
|
git reset --hard origin/$BRANCH
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo "Installing dependencies..."
|
composer install \
|
||||||
composer install --no-dev --optimize-autoloader --no-interaction --no-progress
|
--no-dev \
|
||||||
|
--optimize-autoloader \
|
||||||
|
--no-interaction
|
||||||
|
|
||||||
echo "Running migrations..."
|
|
||||||
php artisan migrate --force
|
php artisan migrate --force
|
||||||
|
|
||||||
echo "Optimizing..."
|
|
||||||
php artisan optimize
|
php artisan optimize
|
||||||
|
|
||||||
|
php artisan queue:restart || true
|
||||||
|
|
||||||
echo "Deploy completed."
|
echo "Deploy completed."
|
||||||
|
|||||||
Reference in New Issue
Block a user