-
Notifications
You must be signed in to change notification settings - Fork 1
95 lines (74 loc) · 2.97 KB
/
ci.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
name: Default Project CI
on: push
jobs:
tests:
runs-on: ubuntu-22.04
env:
PROJECT_NAME: my-project
steps:
- name: Checkout repo
uses: actions/checkout@v4
- name: Setup default environment
run: cp .env.example .env
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Build Docker images
uses: docker/bake-action@v3
with:
load: true
files: |
docker-compose.yml
targets: |
php-fpm
set: |
*.cache-from=type=gha,scope=${{github.ref}}
*.cache-from=type=gha,scope=refs/heads/main
*.cache-to=type=gha,scope=${{github.ref}},mode=max
- name: Build Docker containers and start them
run: docker compose up -d mysql mysql-test php-fpm --wait --no-build
- name: Cache composer dependencies
uses: actions/cache@v3
with:
path: vendor
key: composer-${{ hashFiles('composer.lock') }}
- name: Install PHP Dependencies
run: docker exec "$PROJECT_NAME-php-fpm" /usr/bin/env sh -c "COMPOSER_ALLOW_SUPERUSER=1 composer install --no-interaction --no-scripts --no-progress --prefer-dist"
- name: Failure debug
if: ${{ failure() }}
run: |
docker ps -a
docker logs --timestamps "$PROJECT_NAME-php-fpm"
docker logs --timestamps "$PROJECT_NAME-mysql"
docker inspect "$PROJECT_NAME-php-fpm"
docker inspect "$PROJECT_NAME-mysql"
- name: Cache npm dependencies
uses: actions/cache@v3
with:
path: node_modules
key: npm-${{ hashFiles('package-lock.json') }}
- name: Set up Volta to manage Node/Npm versions
uses: volta-cli/action@v4
- name: Install JS dependencies
run: npm install && npm run build
- name: Cache routes
run: docker exec "$PROJECT_NAME-php-fpm" ./artisan route:cache
- name: Cache views
run: docker exec "$PROJECT_NAME-php-fpm" ./artisan view:cache
- name: Cache Larastan result cache
uses: actions/cache@v3
with:
path: .phpstan.cache
key: "phpstan-result-cache-${{ github.run_id }}" # always unique key - always writes a new cache
restore-keys: | # prefix allows it to use previous cache as starting point
phpstan-result-cache-
- name: Run CI tools
run: docker exec "$PROJECT_NAME-php-fpm" /usr/bin/env sh -c "COMPOSER_MEMORY_LIMIT=-1 composer ci"
- name: Check logs if you need to debug a failing test
if: ${{ failure() }}
run: docker exec "$PROJECT_NAME-php-fpm" cat storage/logs/laravel.log
- name: Deploy to staging if develop branch
if: github.ref == 'refs/heads/develop'
run: curl -s ${{ secrets.ENVOYER_STAGING_TRIGGER }}
- name: Deploy to prod if main branch
if: github.ref == 'refs/heads/main'
run: curl -s ${{ secrets.ENVOYER_PROD_TRIGGER }}