Skip to content

Instantly share code, notes, and snippets.

@devhammed
Created October 26, 2024 08:10
Show Gist options
  • Save devhammed/1dd183b036204a0fd9558cd79e27e428 to your computer and use it in GitHub Desktop.
Save devhammed/1dd183b036204a0fd9558cd79e27e428 to your computer and use it in GitHub Desktop.
Laravel GitHub Actions Deployment Workflow (Filament, Scheduler, Queue, Reverb, Pulse, NPM)
name: Deploy to Servers
on:
push:
branches:
- production
jobs:
production-deploy:
runs-on: ubuntu-latest
if: github.ref_name == 'production'
steps:
- name: Configure SSH
run: |
which ssh-agent || ( apt-get update -y && apt-get install openssh-client -y )
eval $(ssh-agent -s)
echo "${{ secrets.SSH_PRIVATE_KEY }}" | tr -d "\r" | ssh-add -
echo "SSH_AUTH_SOCK=${SSH_AUTH_SOCK}" >> $GITHUB_ENV
- name: Deploy to Production
run: |
ssh -o "StrictHostKeyChecking=no" -p "${{ secrets.SSH_PORT }}" "${{ secrets.SSH_USER }}@${{ secrets.SSH_HOST }}" <<- "ENDSSH"
cd /var/www/html
php artisan down
git fetch --all --tags --prune
git checkout --force production
git pull origin production
composer install --no-ansi --no-dev --no-interaction --no-plugins --no-progress --no-scripts --optimize-autoloader
php artisan optimize:clear
php artisan optimize
php artisan migrate --force
php artisan queue:restart
php artisan reverb:restart
php artisan pulse:restart
php artisan schedule:interrupt
php artisan schedule:clear-cache
php artisan filament:clear-cached-components
php artisan filament:cache-components
npm ci
npm run vite:build
php artisan up
ENDSSH
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment