new: pkg: add CI/CD improvements - add new CI workflow - & improve the deployment w/ tests #10
This commit is contained in:
@@ -6,7 +6,68 @@ on:
|
||||
- 'v*'
|
||||
|
||||
jobs:
|
||||
test:
|
||||
runs-on: splendid-bear
|
||||
|
||||
services:
|
||||
postgres:
|
||||
image: postgres:18-alpine
|
||||
env:
|
||||
POSTGRES_USER: mineseeker_test
|
||||
POSTGRES_PASSWORD: test_password
|
||||
POSTGRES_DB: mineseeker_test
|
||||
options: >-
|
||||
--health-cmd pg_isready
|
||||
--health-interval 10s
|
||||
--health-timeout 5s
|
||||
--health-retries 5
|
||||
ports:
|
||||
- 5432:5432
|
||||
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Setup PHP 8.3
|
||||
uses: shivammathur/setup-php@v2
|
||||
with:
|
||||
php-version: '8.3'
|
||||
extensions: pdo_pgsql, gd, intl, zip, sodium
|
||||
coverage: none
|
||||
tools: composer:v2
|
||||
|
||||
- name: Install PHP dependencies
|
||||
run: composer install --prefer-dist --no-progress --no-interaction
|
||||
|
||||
- name: Setup Node.js
|
||||
uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: '20'
|
||||
|
||||
- name: Install Node dependencies
|
||||
run: npm ci
|
||||
|
||||
- name: Build assets
|
||||
run: npm run build
|
||||
|
||||
- name: Create .env.test file
|
||||
run: |
|
||||
cat > .env.test << 'ENVEOF'
|
||||
APP_ENV=test
|
||||
APP_SECRET=test-secret-key-for-ci-testing-only
|
||||
DATABASE_URL="postgresql://mineseeker_test:test_password@localhost:5432/mineseeker_test?serverVersion=18&charset=utf8"
|
||||
KERNEL_CLASS='App\Kernel'
|
||||
SYMFONY_DEPRECATIONS_HELPER=999999
|
||||
ENVEOF
|
||||
|
||||
- name: Setup test database
|
||||
run: make test-db-setup
|
||||
|
||||
- name: Run PHPUnit tests
|
||||
run: vendor/bin/phpunit --testdox --colors=always --stop-on-failure
|
||||
|
||||
deploy:
|
||||
needs: test
|
||||
runs-on: splendid-bear
|
||||
steps:
|
||||
- name: Checkout tag
|
||||
@@ -33,7 +94,33 @@ jobs:
|
||||
cd "${{ vars.PROD_APP_DIR }}"
|
||||
docker compose build
|
||||
|
||||
- name: Run database migrations
|
||||
run: |
|
||||
cd "${{ vars.PROD_APP_DIR }}"
|
||||
docker compose run --rm app php bin/console doctrine:migrations:migrate --no-interaction
|
||||
|
||||
- name: Clear cache
|
||||
run: |
|
||||
cd "${{ vars.PROD_APP_DIR }}"
|
||||
docker compose run --rm app php bin/console cache:clear --env=prod
|
||||
|
||||
- name: Start services
|
||||
run: |
|
||||
cd "${{ vars.PROD_APP_DIR }}"
|
||||
docker compose up -d
|
||||
|
||||
- name: Health check
|
||||
run: |
|
||||
sleep 5
|
||||
curl -f http://localhost:10080/ || exit 1
|
||||
|
||||
- name: Notify deployment success
|
||||
if: success()
|
||||
run: |
|
||||
echo "✅ Deployment successful for tag ${{ gitea.ref_name }}"
|
||||
|
||||
- name: Notify deployment failure
|
||||
if: failure()
|
||||
run: |
|
||||
echo "❌ Deployment failed for tag ${{ gitea.ref_name }}"
|
||||
exit 1
|
||||
|
||||
Reference in New Issue
Block a user