whisper-money/.github/workflows/ci.yml

177 lines
4.4 KiB
YAML

name: CI
on:
push:
branches:
- develop
- main
pull_request:
branches:
- develop
- main
jobs:
tests:
runs-on: ubuntu-latest
services:
mysql:
image: mysql:8.0
env:
MYSQL_ROOT_PASSWORD: password
MYSQL_DATABASE: testing
ports:
- 3306:3306
options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: 8.4
tools: composer:v2
coverage: xdebug
- name: Setup Bun
uses: oven-sh/setup-bun@v2
- name: Install Node Dependencies
run: bun install --frozen-lockfile
- name: Install Dependencies
run: composer install --no-interaction --prefer-dist --optimize-autoloader
- name: Build Assets
run: bun run build
- name: Copy Environment File
run: cp .env.example .env
- name: Generate Application Key
run: php artisan key:generate
- name: Tests
run: ./vendor/bin/pest --exclude-testsuite=Browser
env:
DB_CONNECTION: mysql
DB_HOST: 127.0.0.1
DB_PORT: 3306
DB_DATABASE: testing
DB_USERNAME: root
DB_PASSWORD: password
browser-tests:
runs-on: ubuntu-latest
services:
mysql:
image: mysql:8.0
env:
MYSQL_ROOT_PASSWORD: password
MYSQL_DATABASE: testing
ports:
- 3306:3306
options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: 8.4
tools: composer:v2
- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: lts/*
- name: Setup Bun
uses: oven-sh/setup-bun@v2
- name: Install Node Dependencies
run: bun install --frozen-lockfile
- name: Install Playwright Browsers
run: npx playwright install --with-deps
- name: Install PHP Dependencies
run: composer install --no-interaction --prefer-dist --optimize-autoloader
- name: Build Assets
run: bun run build
- name: Copy Environment File
run: cp .env.example .env
- name: Generate Application Key
run: php artisan key:generate
- name: Browser Tests
run: ./vendor/bin/pest --testsuite=Browser --ci
env:
DB_CONNECTION: mysql
DB_HOST: 127.0.0.1
DB_PORT: 3306
DB_DATABASE: testing
DB_USERNAME: root
DB_PASSWORD: password
linter:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: '8.4'
- name: Setup Bun
uses: oven-sh/setup-bun@v2
- name: Install Dependencies
run: |
composer install -q --no-ansi --no-interaction --no-scripts --no-progress --prefer-dist
bun install --frozen-lockfile
- name: Run Pint
run: vendor/bin/pint --test
- name: Format Frontend
run: bun run format
- name: Lint Frontend
run: bun run lint
deploy:
runs-on: ubuntu-latest
needs: [tests, browser-tests, linter]
if: github.ref == 'refs/heads/main' && github.event_name == 'push'
steps:
- name: Trigger deployment
run: |
response=$(curl -s -w "\n%{http_code}" \
--connect-timeout 30 \
--max-time 120 \
--retry 3 \
--retry-delay 5 \
--retry-connrefused \
-H "Authorization: Bearer ${{ secrets.DEPLOYMENT_TOKEN }}" \
"http://147.93.126.54:8000/api/v1/deploy?uuid=ww00sswosco8w80k08c0occ8&force=false")
http_code=$(echo "$response" | tail -n1)
body=$(echo "$response" | sed '$d')
echo "Response: $body"
echo "HTTP Status: $http_code"
if [ "$http_code" -lt 200 ] || [ "$http_code" -ge 300 ]; then
echo "Deployment request failed with status $http_code"
exit 1
fi
echo "Deployment triggered successfully!"