/laravel-agent:cicd:setup
Configure CI/CD pipeline for your Laravel application
Overview
The /cicd:setup command provides an interactive wizard to configure continuous integration and deployment pipelines for your Laravel application. It supports GitHub Actions, GitLab CI, and Bitbucket Pipelines, with intelligent detection of your existing tools and customizable pipeline stages.
Usage
/laravel-agent:cicd:setup [platform]
Examples
# Interactive wizard - asks which platform to use
/laravel-agent:cicd:setup
# Configure GitHub Actions directly
/laravel-agent:cicd:setup github
# Configure GitLab CI directly
/laravel-agent:cicd:setup gitlab
# Configure Bitbucket Pipelines directly
/laravel-agent:cicd:setup bitbucket
Supported Platforms
The command supports three major CI/CD platforms:
| Platform | Configuration File | Key Features |
|---|---|---|
| GitHub Actions | .github/workflows/ci.yml |
Matrix testing, parallel jobs, MySQL/Redis services |
| GitLab CI | .gitlab-ci.yml |
Stage-based pipeline, environment deployments |
| Bitbucket Pipelines | bitbucket-pipelines.yml |
PR pipelines, branch-specific deployments |
Setup Process
The wizard walks you through a structured setup process:
1. Environment Check
The command automatically detects your installed tools and dependencies:
# Testing tools detection
composer show pestphp/pest 2>/dev/null && echo "PEST=yes" || echo "PEST=no"
composer show larastan/larastan 2>/dev/null && echo "LARASTAN=yes" || echo "LARASTAN=no"
composer show laravel/pint 2>/dev/null && echo "PINT=yes" || echo "PINT=no"
# Deployment tools detection
composer show laravel/vapor-core 2>/dev/null && echo "VAPOR=yes" || echo "VAPOR=no"
ls -la Dockerfile 2>/dev/null && echo "DOCKER=yes" || echo "DOCKER=no"
2. Platform Selection
If you don't specify a platform in the command, you'll be prompted to choose:
- GitHub Actions
- GitLab CI
- Bitbucket Pipelines
3. Feature Selection
Choose which pipeline stages to include:
- Run tests - Execute Pest/PHPUnit test suite (recommended)
- Code style - Check Laravel Pint formatting (recommended)
- Static analysis - Run Larastan type checking
- Security scan - Run composer audit for vulnerabilities
- Code coverage - Generate and upload to Codecov
- Auto-deploy to staging - Automatic deployment on main branch
- Manual deploy to production - Manual approval workflow
4. Deployment Target
If deployment is enabled, select your deployment target:
- Forge - Laravel Forge deployment hook
- Vapor - Laravel Vapor serverless deployment
- Docker - Custom server with Docker containers
- Bref - AWS Lambda via Bref framework
- None - CI only, no deployment
5. Pipeline Configuration
The command invokes the CI/CD agent to generate your pipeline configuration with your selected options.
6. Results Report
You'll receive a comprehensive summary of what was configured and next steps.
GitHub Actions Configuration
For GitHub Actions (/cicd:setup github), the command creates:
Files Created
.github/
└── workflows/
├── ci.yml # Main CI pipeline
└── deploy.yml # Deployment workflow (if enabled)
Pipeline Features
- Matrix testing across PHP 8.2 and 8.3
- MySQL and Redis service containers
- Parallel lint and security jobs
- Forge or Vapor deployment integration
- Caching for Composer dependencies
Example Workflow
name: CI
on:
push:
branches: [main]
pull_request:
branches: [main]
jobs:
tests:
runs-on: ubuntu-latest
strategy:
matrix:
php: [8.2, 8.3]
services:
mysql:
image: mysql:8.0
env:
MYSQL_DATABASE: testing
MYSQL_ROOT_PASSWORD: password
redis:
image: redis:alpine
steps:
- uses: actions/checkout@v3
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: $
extensions: mbstring, pdo_mysql, redis
- name: Install dependencies
run: composer install --prefer-dist --no-progress
- name: Run tests
run: php artisan test
env:
DB_CONNECTION: mysql
DB_DATABASE: testing
REDIS_HOST: redis
GitLab CI Configuration
For GitLab CI (/cicd:setup gitlab), the command creates:
Files Created
.gitlab-ci.yml # Complete pipeline configuration
Pipeline Stages
- build - Install Composer dependencies
- test - Run Pest/PHPUnit tests
- lint - Code style checking with Pint
- security - Security scanning
- deploy - Environment-based deployments
Example Configuration
stages:
- build
- test
- lint
- security
- deploy
variables:
MYSQL_DATABASE: testing
MYSQL_ROOT_PASSWORD: password
services:
- mysql:8.0
- redis:alpine
build:
stage: build
image: php:8.3
script:
- composer install --prefer-dist --no-progress
cache:
paths:
- vendor/
test:
stage: test
image: php:8.3
services:
- mysql:8.0
- redis:alpine
script:
- php artisan test
Bitbucket Pipelines Configuration
For Bitbucket Pipelines (/cicd:setup bitbucket), the command creates:
Files Created
bitbucket-pipelines.yml # Complete pipeline configuration
Pipeline Features
- Pull request specific pipelines
- Branch-specific deployment rules
- Service containers for MySQL and Redis
- Cached dependencies for faster builds
Required Secrets
After configuration, you'll need to add repository secrets depending on your deployment target:
| Deployment Target | Required Secrets |
|---|---|
| Laravel Forge | FORGE_DEPLOY_URL |
| Laravel Vapor | VAPOR_API_TOKEN |
| Codecov | CODECOV_TOKEN |
| Custom Docker | SSH_PRIVATE_KEY, SERVER_HOST |
Branch Protection
After setting up your pipeline, configure these status checks as required on your main branch:
- tests - All tests must pass
- lint - Code style must be clean
- security - No security vulnerabilities
Example Output Report
After successful configuration, you'll receive a detailed report:
## CI/CD Pipeline Configured: GitHub Actions
### Pipeline Stages
1. Build - Install dependencies
2. Test - Run Pest tests with MySQL/Redis
3. Lint - Laravel Pint code style
4. Security - Composer audit
5. Deploy - Forge (staging auto, production manual)
### Files Created
- .github/workflows/ci.yml
- .github/workflows/deploy.yml
### Required Secrets
Add these to your repository secrets:
- [ ] FORGE_DEPLOY_URL
- [ ] CODECOV_TOKEN (if coverage enabled)
### Branch Protection
Configure these status checks as required:
- tests
- lint
- security
### Test Run
Create a PR to trigger the pipeline.
Best Practices
- Start simple - Begin with tests and linting, add deployment later
- Use caching - Cache Composer dependencies to speed up builds
- Matrix testing - Test on multiple PHP versions (8.2, 8.3)
- Parallel jobs - Run independent jobs (lint, security) in parallel
- Environment parity - Match CI services (MySQL, Redis) to production
- Auto-deploy staging - Deploy staging automatically, production manually
- Status checks - Require CI to pass before merging PRs
- Security scanning - Run composer audit to detect vulnerabilities
Testing Your Pipeline
After configuration, test your pipeline:
- Create a new branch:
git checkout -b test-ci - Make a small change and commit
- Push the branch:
git push origin test-ci - Create a pull request
- Watch the pipeline run in your platform's UI
- Verify all stages pass successfully
Troubleshooting
Tests Failing
- Verify database migrations run before tests
- Check environment variables are set correctly
- Ensure service containers (MySQL, Redis) are accessible
Deployment Issues
- Confirm deployment secrets are added to repository
- Check webhook URLs are correct for Forge
- Verify API tokens have sufficient permissions
Build Timeouts
- Enable dependency caching
- Use
--prefer-distfor Composer installs - Consider parallel job execution
Related Agent
This command uses the laravel-cicd agent to generate pipeline configurations.
See Also
- /laravel-agent:test:make - Generate tests for CI pipeline
- /laravel-agent:deploy:setup - Configure deployment environments