This commit is contained in:
2026-03-13 16:52:12 +01:00
parent 703c602905
commit c9fc1f0190
6 changed files with 114 additions and 2 deletions

34
.env.staging.example Normal file
View File

@@ -0,0 +1,34 @@
# Staging environment variables
# Copy to .env.staging and fill in values
# Database password for the staging Postgres container
STAGING_DB_PASSWORD=""
# Root admin email (auto-promoted to admin on login)
ROOT_ADMIN_EMAIL=""
# Better Auth — must be different from production!
# Generate: openssl rand -hex 16
BETTER_AUTH_SECRET=""
# osu! OAuth — separate app from production
# Register at https://osu.ppy.sh/home/account/edit
# Callback URL: https://staging.esports.vash.software/api/auth/oauth2/callback/osu
OSU_CLIENT_ID=""
OSU_CLIENT_SECRET=""
# osu! IRC — separate account from production to avoid conflicts
# Get credentials at https://osu.ppy.sh/p/irc
OSU_IRC_USERNAME=""
OSU_IRC_PASSWORD=""
# Discord — optional, use a staging channel or leave blank to disable
DISCORD_BOT_TOKEN=""
DISCORD_MATCH_CHANNEL_ID=""
# Cloudflare R2 — can share with production (read-only image cache)
R2_ACCOUNT_ID=""
R2_ACCESS_KEY_ID=""
R2_SECRET_ACCESS_KEY=""
R2_BUCKET="vash-esports-images"
R2_PUBLIC_URL="https://cdn.esports.vash.software"

33
.github/workflows/ci.yml vendored Normal file
View File

@@ -0,0 +1,33 @@
name: CI
on:
push:
branches: [dev, staging, prod]
pull_request:
branches: [dev, staging, prod]
jobs:
ci:
name: Lint, Check & Build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: oven-sh/setup-bun@v2
with:
bun-version: latest
- name: Install dependencies
run: bun install --frozen-lockfile
- name: Lint
run: bun run lint
- name: Type check
run: bun run check
- name: Build
run: bun run build
- name: Tests
run: bun test

44
.github/workflows/deploy.yml vendored Normal file
View File

@@ -0,0 +1,44 @@
name: Deploy
on:
push:
branches: [staging, prod]
jobs:
deploy:
name: Deploy to ${{ github.ref_name }}
runs-on: ubuntu-latest
environment: ${{ github.ref_name == 'prod' && 'production' || 'staging' }}
concurrency:
group: deploy-${{ github.ref_name }}
cancel-in-progress: false
steps:
- name: Deploy via SSH
uses: appleboy/ssh-action@v1
with:
host: ${{ secrets.DEPLOY_HOST }}
username: ${{ secrets.DEPLOY_USER }}
key: ${{ secrets.DEPLOY_SSH_KEY }}
script_stop: true
script: |
set -euo pipefail
if [ "${{ github.ref_name }}" = "prod" ]; then
cd /opt/esports
git fetch origin prod
git checkout prod
git reset --hard origin/prod
docker compose build
docker compose up -d
docker compose exec app bun run db:push
else
cd /opt/esports-staging
git fetch origin staging
git checkout staging
git reset --hard origin/staging
docker compose -f docker-compose.staging.yml --env-file .env.staging -p esports-staging build
docker compose -f docker-compose.staging.yml --env-file .env.staging -p esports-staging up -d
docker compose -f docker-compose.staging.yml --env-file .env.staging -p esports-staging exec staging-app bun run db:push
fi

1
.gitignore vendored
View File

@@ -16,6 +16,7 @@ Thumbs.db
.env .env
.env.* .env.*
!.env.example !.env.example
!.env.staging.example
!.env.test !.env.test
# Vite # Vite

View File

@@ -14,7 +14,7 @@
"lint": "prettier --check . && eslint .", "lint": "prettier --check . && eslint .",
"format": "prettier --write .", "format": "prettier --write .",
"test:unit": "vitest", "test:unit": "vitest",
"test": "npm run test:unit -- --run && npm run test:e2e", "test": "bun run test:unit -- --run && bun run test:e2e",
"test:e2e": "playwright test", "test:e2e": "playwright test",
"db:push": "drizzle-kit push", "db:push": "drizzle-kit push",
"db:generate": "drizzle-kit generate", "db:generate": "drizzle-kit generate",

View File

@@ -1,6 +1,6 @@
import { defineConfig } from '@playwright/test'; import { defineConfig } from '@playwright/test';
export default defineConfig({ export default defineConfig({
webServer: { command: 'npm run build && npm run preview', port: 4173 }, webServer: { command: 'bun run build && bun run preview', port: 4173 },
testDir: 'e2e' testDir: 'e2e'
}); });