Deploy Laravel Application action
name: Deploy Laravel Application
on: push: branches: [ "master" ] pull_request: branches: [ "master" ]
jobs: deploy: runs-on: ubuntu-latest
steps: - name: Checkout Repository uses: actions/checkout@v4
- name: Install sshpass run: sudo apt-get update && sudo apt-get install -y sshpass
- name: Deploy to Production env: DEPLOY_SERVER: ${{ secrets.DEPLOY_SERVER }} DEPLOY_USER: ${{ secrets.DEPLOY_USER }} DEPLOY_PASSWORD: ${{ secrets.DEPLOY_PASSWORD }} run: | # Deploy to the server sshpass -p "$DEPLOY_PASSWORD" ssh -o StrictHostKeyChecking=no $DEPLOY_USER@$DEPLOY_SERVER << EOF # Navigate to the project directory cd /var/www/html/track360
# Pull the latest code from the master branch git pull origin master
# Install production dependencies composer install --no-dev --prefer-dist --optimize-autoloader
# Run database migrations php artisan migrate
# Clear the application cache php artisan cache:clear
# Re-cache the configuration php artisan config:cache
# Restart the queue workers (if using queues) php artisan queue:restart EOF