GitLab CI for Laravel: tests, build, and deploy
A minimal but reliable GitLab CI pipeline for a Laravel app: run tests, build assets, and deploy only when green.
CI/CDGitLabLaravelDevOps
We wanted every merge to main to run the full test suite and asset build, and only then allow deploy. GitLab CI gave us a single place to define those steps and visibility into who broke the pipeline.
We used a PHP image with the right version, installed Composer and Node dependencies, ran migrations and tests against a test database, and built front-end assets. The deploy job only ran when all of that succeeded.
Caching Composer and npm between jobs cut pipeline time significantly. We kept secrets in GitLab CI variables and avoided storing credentials in the repo. The result was a predictable path from commit to production.