Skip to content

Commit b601e6f

Browse files
committed
chore: rename publish workflow to build-and-publish and enhance CI process with testing steps
1 parent c868a50 commit b601e6f

File tree

2 files changed

+76
-82
lines changed

2 files changed

+76
-82
lines changed
Lines changed: 76 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Docker Image CI
1+
name: Laravel
22

33
on:
44
push:
@@ -10,7 +10,81 @@ env:
1010
IMAGE_NAME: ${{ github.repository }}
1111

1212
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+
uses: actions/[email protected]
84+
with:
85+
name: laravel-app
86+
87+
publish:
1488
runs-on: ubuntu-latest
1589

1690
permissions:

.github/workflows/build.yml

Lines changed: 0 additions & 80 deletions
This file was deleted.

0 commit comments

Comments
 (0)