Skip to content

Instantly share code, notes, and snippets.

@mzarallo
Last active December 16, 2022 22:09
Show Gist options
  • Save mzarallo/0677bd2248738ae12006c3fb7e33cc82 to your computer and use it in GitHub Desktop.
Save mzarallo/0677bd2248738ae12006c3fb7e33cc82 to your computer and use it in GitHub Desktop.
Laravel 9 pipeline for Github action self hosted runner
name: Build & Test
on:
push:
branches:
- "**"
paths:
- ".github/**"
- "app/**"
- "config/**"
- "database/**"
- "routes/**"
- "resources/**"
- "tests/**"
- "package.json"
- "package-lock.json"
- "composer.json"
- "composer.lock"
pull_request:
branches:
- "**"
paths:
- ".github/**"
- "app/**"
- "config/**"
- "database/**"
- "routes/**"
- "resources/**"
- "tests/**"
- "package.json"
- "package-lock.json"
- "composer.json"
- "composer.lock"
- ".env.ci"
jobs:
laravel-ci:
name: Build & Test
runs-on:
- self-hosted
steps:
- uses: actions/checkout@v3
- name: Copy .env
run: cp .env.ci .env
- name: Install Dependencies Composer
run: composer install -q --no-ansi --no-interaction --no-scripts --no-progress --prefer-dist
- name: Generate key
run: php artisan key:generate
- name: Caching laravel configuration
run: php artisan config:cache && php artisan route:cache && php artisan view:cache
- name: Directory Permissions
run: chmod -R 777 storage bootstrap/cache
- name: Install Dependencies Npm
run: npm ci
- name: Vite build
run: npm run build
- name: Execute tests (Unit and Feature tests) via PHPUnit
run: php artisan test --parallel
- name: Install Chrome driver
run: php artisan dusk:chrome-driver --detect
- name: Start Chrome Driver
run: ./vendor/laravel/dusk/bin/chromedriver-linux > /dev/null 2>&1 &
- name: Run migrations and seeders
run: php artisan migrate:fresh --seed --force
- name: Run Laravel Server
run: php artisan serve > /dev/null 2>&1 &
- name: Run Dusk Tests
run: |
chmod -R 0755 vendor/laravel/dusk/bin/
php artisan dusk
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment