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 }} password: ${{ secrets.PASSWORD }} port: ${{ secrets.PORT }} script_stop: true script: | set -ex export PATH="$HOME/.phpenv/shims:$PATH" umask 002 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 mkdir -p storage/framework/{cache,sessions,views} storage/logs bootstrap/cache chmod -R u+rwX storage bootstrap/cache vendor 2>/dev/null || true if test -e vendor/composer/installed.php && ! test -w vendor/composer/installed.php; then echo "vendor/composer/installed.php is not writable by $(whoami). Current ownership:" ls -ld vendor vendor/composer vendor/composer/installed.php exit 1 fi if test -d vendor/composer && ! test -w vendor/composer; then echo "vendor/composer is not writable by $(whoami). Current ownership:" ls -ld vendor vendor/composer exit 1 fi composer install composer dump-autoload php artisan migrate --force php artisan config:clear php artisan optimize php artisan queue:restart || true echo "Deploy completed."