Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 40 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -82,3 +82,43 @@ jobs:

- name: Run tests
run: npm test

# ─── Indexer CI ─────────────────────────────────────────────────────────
indexer:
name: Indexer (TypeScript + Prisma)
runs-on: ubuntu-latest
defaults:
run:
working-directory: indexer
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
cache: 'npm'
cache-dependency-path: indexer/package-lock.json

- name: Install dependencies
run: npm ci

# Cache the generated Prisma client so it is not rebuilt unless the
# schema changes. The cache key includes the schema hash so any model
# change automatically invalidates it.
- name: Cache Prisma generated client
id: prisma-cache
uses: actions/cache@v4
with:
path: indexer/node_modules/.prisma
key: prisma-${{ runner.os }}-${{ hashFiles('indexer/prisma/schema.prisma') }}
restore-keys: |
prisma-${{ runner.os }}-

- name: Generate Prisma client
if: steps.prisma-cache.outputs.cache-hit != 'true'
run: npm run prisma:generate

- name: Build
run: npm run build
168 changes: 168 additions & 0 deletions .github/workflows/deploy-react.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,168 @@
# .github/workflows/deploy-react.yml
#
# Vercel Deployment — bc-forge React App (Issue #336)
#
# Triggers:
# • push to main → production deployment
# • pull_request → preview deployment (URL posted as PR comment)
#
# Required repository secrets (Settings → Secrets and variables → Actions):
# VERCEL_TOKEN – Vercel personal access token
# VERCEL_ORG_ID – Vercel organisation / team ID
# VERCEL_PROJECT_ID – Vercel project ID (from .vercel/project.json)

name: Deploy React App to Vercel

on:
push:
branches: [main]
paths:
- 'react/**'
- '.github/workflows/deploy-react.yml'
pull_request:
branches: [main]
paths:
- 'react/**'

jobs:
# ─── Build & Test ──────────────────────────────────────────────────────────
build:
name: Build & Test React App
runs-on: ubuntu-latest
defaults:
run:
working-directory: react

steps:
- name: Checkout
uses: actions/checkout@v4

- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
cache: 'npm'
cache-dependency-path: react/package-lock.json

- name: Install dependencies
run: npm ci

- name: Run tests
run: npm test

- name: Build
run: npm run build

- name: Upload build artifact
uses: actions/upload-artifact@v4
with:
name: react-dist
path: react/dist
retention-days: 1

# ─── Vercel Preview (PRs) ──────────────────────────────────────────────────
deploy-preview:
name: Vercel Preview Deployment
runs-on: ubuntu-latest
needs: build
if: github.event_name == 'pull_request'
environment:
name: preview
url: ${{ steps.deploy.outputs.preview-url }}

steps:
- name: Checkout
uses: actions/checkout@v4

- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
cache: 'npm'
cache-dependency-path: react/package-lock.json

- name: Install Vercel CLI
run: npm install --global vercel@latest

- name: Pull Vercel environment
run: vercel pull --yes --environment=preview --token=${{ secrets.VERCEL_TOKEN }}
working-directory: react
env:
VERCEL_ORG_ID: ${{ secrets.VERCEL_ORG_ID }}
VERCEL_PROJECT_ID: ${{ secrets.VERCEL_PROJECT_ID }}

- name: Build for Vercel (preview)
run: vercel build --token=${{ secrets.VERCEL_TOKEN }}
working-directory: react
env:
VERCEL_ORG_ID: ${{ secrets.VERCEL_ORG_ID }}
VERCEL_PROJECT_ID: ${{ secrets.VERCEL_PROJECT_ID }}

- name: Deploy to Vercel (preview)
id: deploy
run: |
PREVIEW_URL=$(vercel deploy --prebuilt --token=${{ secrets.VERCEL_TOKEN }})
echo "preview-url=$PREVIEW_URL" >> "$GITHUB_OUTPUT"
working-directory: react
env:
VERCEL_ORG_ID: ${{ secrets.VERCEL_ORG_ID }}
VERCEL_PROJECT_ID: ${{ secrets.VERCEL_PROJECT_ID }}

- name: Comment preview URL on PR
uses: actions/github-script@v7
with:
script: |
github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: `## ✅ Vercel Preview Deployment\n\n🔗 **Preview URL:** ${{ steps.deploy.outputs.preview-url }}\n\n> Deployed from commit \`${{ github.sha }}\``
})

# ─── Vercel Production (main) ──────────────────────────────────────────────
deploy-production:
name: Vercel Production Deployment
runs-on: ubuntu-latest
needs: build
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
environment:
name: production
url: ${{ steps.deploy.outputs.production-url }}

steps:
- name: Checkout
uses: actions/checkout@v4

- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
cache: 'npm'
cache-dependency-path: react/package-lock.json

- name: Install Vercel CLI
run: npm install --global vercel@latest

- name: Pull Vercel environment
run: vercel pull --yes --environment=production --token=${{ secrets.VERCEL_TOKEN }}
working-directory: react
env:
VERCEL_ORG_ID: ${{ secrets.VERCEL_ORG_ID }}
VERCEL_PROJECT_ID: ${{ secrets.VERCEL_PROJECT_ID }}

- name: Build for Vercel (production)
run: vercel build --prod --token=${{ secrets.VERCEL_TOKEN }}
working-directory: react
env:
VERCEL_ORG_ID: ${{ secrets.VERCEL_ORG_ID }}
VERCEL_PROJECT_ID: ${{ secrets.VERCEL_PROJECT_ID }}

- name: Deploy to Vercel (production)
id: deploy
run: |
PROD_URL=$(vercel deploy --prebuilt --prod --token=${{ secrets.VERCEL_TOKEN }})
echo "production-url=$PROD_URL" >> "$GITHUB_OUTPUT"
working-directory: react
env:
VERCEL_ORG_ID: ${{ secrets.VERCEL_ORG_ID }}
VERCEL_PROJECT_ID: ${{ secrets.VERCEL_PROJECT_ID }}
Loading
Loading