Skip to content

update deployer en recipe #166

update deployer en recipe

update deployer en recipe #166

Workflow file for this run

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 }}