Remove: root Expo typecheck/lint/test/build-check (project deleted Apr 19) Remove: swift-build-test + app-store.yml (no macOS runner on Gitea) Add: path-filtered conditional jobs with dorny/paths-filter@v3 Add: youtube-worker deploy to deploy-functions job Fix: deploy-functions always() to handle skipped upstream jobs Fix: SPM cache key includes Package.resolved (before removal) Fix: remove continue-on-error from vitest/playwright steps
162 lines
5.1 KiB
YAML
162 lines
5.1 KiB
YAML
name: CI
|
|
|
|
on:
|
|
push:
|
|
branches: [main]
|
|
pull_request:
|
|
branches: [main]
|
|
|
|
jobs:
|
|
# ── Path filter — determines which downstream jobs run ──
|
|
changes:
|
|
name: Detect Changes
|
|
runs-on: ubuntu-latest
|
|
outputs:
|
|
admin-web: ${{ steps.filter.outputs.admin-web }}
|
|
youtube-worker: ${{ steps.filter.outputs.youtube-worker }}
|
|
supabase-functions: ${{ steps.filter.outputs.supabase-functions }}
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
|
|
- uses: dorny/paths-filter@v3
|
|
id: filter
|
|
with:
|
|
filters: |
|
|
admin-web:
|
|
- 'admin-web/**'
|
|
- '.github/workflows/ci.yml'
|
|
youtube-worker:
|
|
- 'youtube-worker/**'
|
|
- '.github/workflows/ci.yml'
|
|
supabase-functions:
|
|
- 'supabase/functions/**'
|
|
- 'youtube-worker/**'
|
|
- '.github/workflows/ci.yml'
|
|
|
|
# ── Admin Web: Next.js ──
|
|
admin-web-test:
|
|
name: Admin Web CI
|
|
needs: changes
|
|
if: needs.changes.outputs.admin-web == 'true'
|
|
runs-on: ubuntu-latest
|
|
defaults:
|
|
run:
|
|
working-directory: admin-web
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
|
|
- name: Setup Node.js
|
|
uses: actions/setup-node@v4
|
|
with:
|
|
node-version: '20'
|
|
cache: 'npm'
|
|
cache-dependency-path: admin-web/package-lock.json
|
|
|
|
- name: Install dependencies
|
|
run: npm ci
|
|
|
|
- name: Type check
|
|
run: npx tsc --noEmit
|
|
|
|
- name: Run unit tests
|
|
run: npx vitest run
|
|
|
|
- name: Install Playwright browsers
|
|
run: npx playwright install --with-deps chromium
|
|
|
|
- name: Run E2E tests
|
|
run: npx playwright test
|
|
|
|
# ── YouTube Worker: Node.js microservice ──
|
|
youtube-worker-check:
|
|
name: YouTube Worker
|
|
needs: changes
|
|
if: needs.changes.outputs.youtube-worker == 'true'
|
|
runs-on: ubuntu-latest
|
|
defaults:
|
|
run:
|
|
working-directory: youtube-worker
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
|
|
- name: Setup Node.js
|
|
uses: actions/setup-node@v4
|
|
with:
|
|
node-version: '20'
|
|
cache: 'npm'
|
|
cache-dependency-path: youtube-worker/package-lock.json
|
|
|
|
- name: Install dependencies
|
|
run: npm ci
|
|
|
|
- name: Validate syntax
|
|
run: node --check server.js
|
|
|
|
# ── Deploy: Supabase edge functions + YouTube worker ──
|
|
deploy-functions:
|
|
name: Deploy
|
|
needs: [changes, admin-web-test, youtube-worker-check]
|
|
if: |
|
|
always() &&
|
|
github.ref == 'refs/heads/main' &&
|
|
github.event_name == 'push' &&
|
|
!contains(needs.*.result, 'failure') &&
|
|
(needs.changes.outputs.supabase-functions == 'true' ||
|
|
needs.changes.outputs.youtube-worker == 'true')
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
|
|
- name: Setup SSH
|
|
env:
|
|
DEPLOY_HOST: ${{ secrets.SUPABASE_DEPLOY_HOST }}
|
|
run: |
|
|
mkdir -p ~/.ssh
|
|
echo "${{ secrets.SUPABASE_SSH_KEY }}" > ~/.ssh/deploy_key
|
|
chmod 600 ~/.ssh/deploy_key
|
|
ssh-keyscan -H $DEPLOY_HOST >> ~/.ssh/known_hosts 2>/dev/null
|
|
|
|
- name: Deploy Supabase Edge Functions
|
|
env:
|
|
DEPLOY_HOST: ${{ secrets.SUPABASE_DEPLOY_HOST }}
|
|
DEPLOY_USER: ${{ secrets.SUPABASE_DEPLOY_USER }}
|
|
DEPLOY_PATH: ${{ secrets.SUPABASE_DEPLOY_PATH }}
|
|
run: |
|
|
rsync -avz --delete \
|
|
--exclude='node_modules' \
|
|
--exclude='.DS_Store' \
|
|
-e "ssh -i ~/.ssh/deploy_key" \
|
|
supabase/functions/ \
|
|
"$DEPLOY_USER@$DEPLOY_HOST:$DEPLOY_PATH/"
|
|
ssh -i ~/.ssh/deploy_key "$DEPLOY_USER@$DEPLOY_HOST" \
|
|
"docker restart supabase-edge-functions"
|
|
|
|
- name: Deploy YouTube Worker
|
|
env:
|
|
DEPLOY_HOST: ${{ secrets.SUPABASE_DEPLOY_HOST }}
|
|
DEPLOY_USER: ${{ secrets.SUPABASE_DEPLOY_USER }}
|
|
WORKER_PATH: /opt/supabase/youtube-worker
|
|
run: |
|
|
rsync -avz --delete \
|
|
--exclude='node_modules' \
|
|
--exclude='.DS_Store' \
|
|
-e "ssh -i ~/.ssh/deploy_key" \
|
|
youtube-worker/ \
|
|
"$DEPLOY_USER@$DEPLOY_HOST:$WORKER_PATH/"
|
|
ssh -i ~/.ssh/deploy_key "$DEPLOY_USER@$DEPLOY_HOST" "\
|
|
cd $WORKER_PATH && \
|
|
docker build -t youtube-worker:latest . && \
|
|
docker stop youtube-worker 2>/dev/null || true && \
|
|
docker rm youtube-worker 2>/dev/null || true && \
|
|
docker run -d \
|
|
--name youtube-worker \
|
|
--restart unless-stopped \
|
|
--network supabase_supabase-network \
|
|
-e SUPABASE_URL=\$(docker exec supabase-edge-functions printenv SUPABASE_URL) \
|
|
-e SUPABASE_SERVICE_ROLE_KEY=\$(docker exec supabase-edge-functions printenv SUPABASE_SERVICE_ROLE_KEY) \
|
|
-e SUPABASE_PUBLIC_URL=https://supabase.1000co.fr \
|
|
-e GEMINI_API_KEY=\$(cat /opt/supabase/.env.gemini 2>/dev/null || echo '') \
|
|
-e STORAGE_BUCKET=workout-audio \
|
|
-e PORT=3001 \
|
|
youtube-worker:latest"
|