Files
portal-api/.github/workflows/deploy.yml
T

63 lines
1.6 KiB
YAML

name: Deploy Portal API
on:
push:
branches:
- production
workflow_dispatch:
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- name: Deploy
uses: appleboy/ssh-action@v1.2.0
with:
host: ${{ secrets.HOST }}
username: ${{ secrets.USERNAME }}
key: ${{ secrets.SSH_PRIVATE_KEY }}
port: ${{ secrets.PORT }}
script_stop: true
script: |
set -ex
export PATH="$HOME/.phpenv/shims:$PATH"
php -v
BRANCH="production"
REPO_URL="${{ secrets.REPO_URL }}"
cd httpdocs
pwd
ls -la
if [ ! -d ".git" ]; then
echo "First deploy..."
rm -rf ./*
git clone -b "$BRANCH" "$REPO_URL" .
else
echo "Updating source..."
git fetch origin
git reset --hard origin/$BRANCH
fi
composer install \
--no-dev \
--optimize-autoloader \
--no-interaction
php artisan migrate --force
php artisan optimize
php artisan queue:restart || true
echo "Deploy completed."