// DevOps public function show() { return 'GitHub Actions: CI/CD cho Laravel Projec...'; }

Setup GitHub Actions

Tạo file .github/workflows/laravel.yml:

name: Laravel CI

on:
  push:
    branches: [ main ]
  pull_request:
    branches: [ main ]

jobs:
  test:
    runs-on: ubuntu-latest
    
    services:
      mysql:
        image: mysql:8.0
        env:
          MYSQL_ROOT_PASSWORD: password
          MYSQL_DATABASE: laravel_test
    
    steps:
    - uses: actions/checkout@v3
    
    - name: Setup PHP
      uses: shivammathur/setup-php@v2
      with:
        php-version: '8.2'
    
    - name: Install Dependencies
      run: composer install
    
    - name: Run Tests
      env:
        DB_CONNECTION: mysql
        DB_DATABASE: laravel_test
        DB_USERNAME: root
        DB_PASSWORD: password
      run: php artisan test

Kết luận

GitHub Actions giúp tự động hóa testing và deployment.