Skip to main content
AT

GitHub Actions CI/CD for Laravel - my production workflow

Alex Thompson Cloud & DevOps 274 views
Sharing my GitHub Actions workflow that I use for deploying Laravel apps. It runs PHPStan, Pint, and PHPUnit before deploying via SSH. The workflow has two jobs: 1. Test job: Checkout code, setup PHP 8.3, composer install, run vendor/bin/pint --test, run vendor/bin/phpstan analyse, run php artisan test. 2. Deploy job (depends on test passing): rsync files to server, run composer install --no-dev, clear and rebuild caches. The key insight: always run Pint in --test mode in CI. It catches formatting issues without modifying files. Also running PHPStan at level 8 catches so many bugs before they reach production. Full workflow file is around 80 lines. Happy to share the complete version if anyone is interested.

2 Replies

EA
Engr Mejba Ahmed 4 months ago
Great workflow Alex! Very similar to what I use for deploying mejba.me and the other sites I manage. A couple of additions I would recommend: 1. Cache Composer dependencies between runs. Saves 30-60 seconds per workflow execution. 2. Use --delete-after with rsync to remove stale files on deploy without causing downtime during the sync. 3. Always run php artisan optimize:clear before rebuilding the cache in production to avoid stale cache issues. One gotcha I learned the hard way: always remove public/hot after deployment if you use Vite. Otherwise production will try to load assets from localhost:5173.
NO
Nina Okafor 4 months ago
Would love to see the full workflow! Also, do you use GitHub environments for staging vs production? I have set up approval gates for production deploys and it has saved us from a few accidents.

Post a Reply

Engr Mejba Ahmed

Engr Mejba Ahmed

Claude Code Expert · Online

👋

Hey there!

Quick Actions

WhatsApp Instant reply

Chat on WhatsApp

+880 1723 741224 · Instant reply

Popular Questions

Engr Mejba Ahmed is connected
Engr Mejba Ahmed is typing...
Engr Mejba Ahmed avatar

✉ Want me to follow up? Drop your email

Engr Mejba Ahmed avatar

📞 Connect Directly

Choose how you'd like to reach me

WhatsApp

+880 1723 741224

Email

[email protected]

✓ Details sent! I'll get back to you shortly.

Powered by OpenAI

335+

Blog Posts

25

AI Courses

63

Projects

Services & Expertise

Pricing & Process

Learning & Resources

Connect & Support