Skip to content

Instantly share code, notes, and snippets.

@nexxai
Last active November 8, 2024 23:24
Show Gist options
  • Select an option

  • Save nexxai/a2c25ab72c5e2223e0b72e30b0431c4c to your computer and use it in GitHub Desktop.

Select an option

Save nexxai/a2c25ab72c5e2223e0b72e30b0431c4c to your computer and use it in GitHub Desktop.
name: Deployment
on:
push:
workflow_dispatch:
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
fabpot-security-checker:
runs-on: ubuntu-latest
steps:
- name: Checkout the repository
uses: actions/checkout@v4
- name: Setup PHP
uses: shivammathur/setup-php@v2
- name: Install security-checker
uses: symfonycorp/security-checker-action@v5
pest:
runs-on: ubuntu-latest
needs: [ fabpot-security-checker, phpcpd ]
services:
mariadb:
image: mariadb:10.11
env:
MYSQL_ROOT_PASSWORD: root
ports:
- 3306:3306
options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3
redis:
image: redis:7.0-alpine
ports:
- 6379:6379
options: >-
--health-cmd "redis-cli ping"
--health-interval 10s
--health-timeout 5s
--health-retries 5
steps:
- name: Checkout the repository
uses: actions/checkout@v4
- name: Setup PHP with composer v2
uses: shivammathur/setup-php@v2
with:
php-version: "8.2"
tools: composer:v2
extensions: dom, curl, libxml, mbstring, zip, pcntl, pdo, sqlite, pdo_sqlite, mysql, mysqli, pdo_mysql, bcmath, soap, intl, gd, exif, iconv, imagick, redis
coverage: xdebug
- name: Install composer packages
run: |
php -v
composer install --prefer-dist --no-ansi --no-interaction --no-progress --no-scripts
- name: npm install
run: |
npm --version
npm install
npm run production
- name: Create temp database
run: |
mysql --host 127.0.0.1 -uroot -proot -e "CREATE DATABASE IF NOT EXISTS laravel_db"
- name: Execute tests
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
run: |
cp .env.github .env
php -v
php artisan migrate --force
php artisan key:generate
./vendor/bin/pest --parallel --coverage-clover=coverage.xml
bash <(curl -s https://codecov.io/bash) || echo 'Codecov failed to upload'
phpstan:
runs-on: ubuntu-latest
needs: [ fabpot-security-checker, phpcpd ]
steps:
- name: Checkout the repository
uses: actions/checkout@v4
- name: Setup PHP with composer v2
uses: shivammathur/setup-php@v2
with:
php-version: "8.2"
extensions: dom, curl, libxml, mbstring, zip, pcntl, pdo, sqlite, pdo_sqlite, mysql, mysqli, pdo_mysql, bcmath, soap, intl, gd, exif, iconv, imagick, redis
tools: composer:v2
- name: Install composer packages
run: |
php -v
composer install --prefer-dist --no-ansi --no-interaction --no-progress --no-scripts
- name: Static analysis with phpstan
run: ./vendor/bin/phpstan analyse
phpcpd:
runs-on: ubuntu-latest
steps:
- name: Checkout the repository
uses: actions/checkout@v4
- name: Setup PHP
uses: shivammathur/setup-php@v2
- name: Install phpcpd
run: test -f phpcpd.phar || curl -L https://phar.phpunit.de/phpcpd.phar -o phpcpd.phar
- name: Run phpcpd
run: php phpcpd.phar app/ --min-lines=50
ploi_deploy:
runs-on: ubuntu-latest
needs: [ pest, phpstan ]
if: github.ref == 'refs/heads/main'
steps:
- name: Trigger Ploi webhook
run: curl -X POST ${{ secrets.PLOI_DEPLOY_WEBHOOK }}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment