-
Notifications
You must be signed in to change notification settings - Fork 0
134 lines (113 loc) · 5.04 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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
name: CI/CD process for Symfony
on:
push:
branches: [ dev, master ]
pull_request:
branches: [ dev, master ]
jobs:
build:
runs-on: ubuntu-latest
services:
mysql:
image: mariadb:10.3
env:
MYSQL_ROOT_PASSWORD: root
MYSQL_DATABASE: symfony
ports:
- 3306/tcp
options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3
strategy:
fail-fast: true
matrix:
php-versions: ['8.1']
steps:
# —— Setup GitHub actions 🐙 —————————————————————————————————————————————
# https://github.com/actions/checkout (official)
- name: Checkout
uses: actions/checkout@v2
# https://github.com/shivammathur/setup-php (community)
- name: Setup PHP, extensions and composer with shivammathur/setup-php
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php-versions }}
extensions: mbstring, xml, ctype, iconv, intl, pdo, pdo_mysql, dom, filter, gd, iconv, json
env:
update: true
- name: Start mysql service
run: sudo service mysql start
- name: Setup problem matchers for PHPUnit
run: echo "::add-matcher::${{ runner.tool_cache }}/phpunit.json"
- name: Check PHP Version
run: php -v
# —— Composer 🧙️ —————————————————————————————————————————————————————————
- name: Validate composer.json and composer.lock
run: composer validate -d app
- name: Check outdated packages
run: composer outdated --direct -d app
- name: Get composer cache directory
id: composer-cache
run: echo "::set-output name=dir::$(composer config cache-files-dir -d app)"
- name: Cache composer dependencies
uses: actions/cache@v1
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
restore-keys: ${{ runner.os }}-composer-
- name: Install Composer dependencies
env:
DATABASE_URL: mysql://root:root@127.0.0.1:${{ job.services.mysql.ports['3306'] }}/symfony?serverVersion=mariadb-10.5.12
run: composer install --no-progress --prefer-dist --optimize-autoloader -d app
## —— Yarn 🐱 ————————————————————————————————————————————————————————————
- name: Yarn setup
uses: actions/setup-node@v2
with:
node-version: '16'
- run: |
cd app
yarn install
- name: Yarn build
run: |
cd app
yarn run encore production
## —— PHPStan ✅ ———————————————————————————————————————————————————————————
- name: Run static analysis with PHPStan
env:
DATABASE_URL: mysql://root:root@127.0.0.1:${{ job.services.mysql.ports['3306'] }}/symfony?serverVersion=mariadb-10.5.12
run: ./app/vendor/bin/phpstan analyse -c app/phpstan.neon
## —— Doctrine 🐱 ————————————————————————————————————————————————————————————
- name: Run Doctrine migrations and load fixtures
env:
DATABASE_URL: mysql://root:root@127.0.0.1:${{ job.services.mysql.ports['3306'] }}/symfony?serverVersion=mariadb-10.5.12
run: |
cd app
php bin/console doctrine:schema:update --force || echo "No migration found or schema update failed"
php bin/console doctrine:migrations:migrate || echo "No migration found or migration failed"
php bin/console doctrine:fixtures:load --append -n || echo "No fixture found or fixtures load failed"
## —— Tests ✅ ———————————————————————————————————————————————————————————
- name: Run tests
env:
APP_ENV: test
APP_SECRET: ''
DATABASE_URL: mysql://root:root@127.0.0.1:${{ job.services.mysql.ports['3306'] }}/symfony?serverVersion=mariadb-10.5.12
run: |
cd app
php bin/phpunit -v
deploy:
name: Deploy to prod
runs-on: ubuntu-latest
needs: build
if: github.ref == 'refs/heads/master'
steps:
- run: echo "Build job was a success on master, deploying..."
- uses: actions/checkout@v2
- name: Setup PHP and Deployer
uses: shivammathur/setup-php@master
with:
php-version: 8.1
- name: Install dependencies
run: composer install
- name: Deploy
uses: deployphp/action@v1
with:
dep: deploy -vvv
private-key: ${{ secrets.PRIVATE_KEY }}