Hornbill LitePress
Alice Nguyen · Laravel ·

CI/CD with GitHub Actions and Laravel

A practical guide to cI/CD with GitHub Actions and Laravel — tips, best practices, and real-world examples.

# CI/CD with GitHub Actions and Laravel

Automate your Laravel testing and deployment with GitHub Actions.

## Basic Workflow

```yaml
name: CI

on: [push, pull_request]

jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: '8.4'

- name: Install Dependencies
run: composer install

- name: Run Tests
run: php artisan test
```

## Deployment Strategy

Use separate workflows for:

- **Testing**: runs on every push
- **Deployment**: runs on main branch after tests pass

## Environment Secrets

Store sensitive data in GitHub Secrets:

- `APP_KEY`
- Database credentials
- API keys

## Best Practices

1. Run lint checks (`./vendor/bin/pint --test`)
2. Use caching for Composer dependencies
3. Matrix testing for multiple PHP versions

## Conclusion

GitHub Actions provides a robust, free CI/CD solution for Laravel projects.
DevOps Laravel Best Practices

Written by

A
Alice Nguyen

Full-stack developer writing about web architecture, Laravel, and open-source tooling.

← Back to Alice Nguyen's posts