|
1 | | -name: Docker Image CI |
| 1 | +name: Laravel |
2 | 2 |
|
3 | 3 | on: |
4 | 4 | push: |
|
10 | 10 | IMAGE_NAME: ${{ github.repository }} |
11 | 11 |
|
12 | 12 | jobs: |
13 | | - build: |
| 13 | + build-and-test: |
| 14 | + runs-on: ubuntu-latest |
| 15 | + |
| 16 | + steps: |
| 17 | + - name: Checkout |
| 18 | + uses: actions/checkout@v4 |
| 19 | + |
| 20 | + # Cache composer and npm dependencies |
| 21 | + - name: Cache Composer dependencies |
| 22 | + uses: actions/cache@v3 |
| 23 | + with: |
| 24 | + path: vendor |
| 25 | + key: composer-${{ hashFiles('**/composer.lock') }} |
| 26 | + restore-keys: | |
| 27 | + composer- |
| 28 | +
|
| 29 | + - name: Cache npm dependencies |
| 30 | + uses: actions/cache@v3 |
| 31 | + with: |
| 32 | + path: node_modules |
| 33 | + key: npm-${{ hashFiles('**/package-lock.json') }} |
| 34 | + restore-keys: | |
| 35 | + npm- |
| 36 | +
|
| 37 | + # Setup PHP |
| 38 | + - uses: shivammathur/setup-php@15c43e89cdef867065b0213be354c2841860869e |
| 39 | + with: |
| 40 | + php-version: "8.2" |
| 41 | + |
| 42 | + # Checkout and prepare repo |
| 43 | + - name: Copy .env |
| 44 | + run: php -r "file_exists('.env') || copy('.env.example', '.env');" |
| 45 | + |
| 46 | + # Install Composer Dependencies |
| 47 | + - name: Install PHP Dependencies |
| 48 | + run: composer install -q --no-ansi --no-interaction --no-scripts --no-progress --prefer-dist |
| 49 | + |
| 50 | + # Install node.js and run npm commands |
| 51 | + - name: Install Node.js |
| 52 | + uses: actions/setup-node@v4 |
| 53 | + with: |
| 54 | + node-version: "20" |
| 55 | + |
| 56 | + - name: Install NPM Dependencies |
| 57 | + run: npm install |
| 58 | + |
| 59 | + - name: Build Assets |
| 60 | + run: npm run build |
| 61 | + |
| 62 | + # Prepare php test environment |
| 63 | + - name: Generate key |
| 64 | + run: php artisan key:generate |
| 65 | + |
| 66 | + - name: Directory Permissions |
| 67 | + run: chmod -R 777 storage bootstrap/cache |
| 68 | + |
| 69 | + - name: Create Database |
| 70 | + run: | |
| 71 | + mkdir -p database |
| 72 | + touch database/database.sqlite |
| 73 | +
|
| 74 | + # Execute tests |
| 75 | + - name: Execute tests (Unit and Feature tests) via PHPUnit/Pest |
| 76 | + env: |
| 77 | + DB_CONNECTION: sqlite |
| 78 | + DB_DATABASE: database/database.sqlite |
| 79 | + run: php artisan test |
| 80 | + |
| 81 | + # Publish Artifact for later use |
| 82 | + - name: Publish Artifact |
| 83 | + |
| 84 | + with: |
| 85 | + name: laravel-app |
| 86 | + |
| 87 | + publish: |
14 | 88 | runs-on: ubuntu-latest |
15 | 89 |
|
16 | 90 | permissions: |
|
0 commit comments