54 lines
1.3 KiB
YAML
54 lines
1.3 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"
|
|
|
|
cd httpdocs
|
|
|
|
if test -d .git; then
|
|
echo "Updating source..."
|
|
|
|
git fetch origin
|
|
|
|
git reset --hard origin/$BRANCH
|
|
else
|
|
echo "First deploy..."
|
|
|
|
git clone -b "$BRANCH" "${{ secrets.REPO_URL }}" .
|
|
fi
|
|
|
|
composer install --no-dev --optimize-autoloader --no-interaction
|
|
|
|
php artisan migrate --force
|
|
|
|
php artisan optimize
|
|
|
|
php artisan queue:restart || true
|
|
|
|
echo "Deploy completed."
|