This guide covers the CI/CD infrastructure for GXQ Studio, including GitHub Actions workflows, automated deployments, and operational procedures.
Push to master/main
↓
GXQ Master CI Pipeline
↓
[validate-environment] → [install-dependencies]
↓
[lint-and-typecheck] → [build-backend] + [build-webapp]
↓
[validate-build] + [security-scan]
↓
[master-ci-summary]
↓
Manual trigger or tag push
↓
GXQ Deploy Production
↓
[prepare-deployment] → [deploy-vercel] + [deploy-railway]
↓
[post-deployment-health]
File: .github/workflows/gxq-master-ci.yml
Triggers:
- Push to
masterormainbranch - Manual workflow dispatch
Purpose: Comprehensive validation and build verification for master branch
Jobs:
- Sets up Node.js 20.x
- Creates mock environment file for CI
- Runs
scripts/env-check.sh
- Installs backend dependencies with
npm ci - Installs webapp dependencies
- Caches
node_modulesfor speed
- Runs ESLint on backend and webapp (non-blocking)
- Runs TypeScript type-checking (blocking)
- Compiles TypeScript backend
- Uploads
dist/artifacts
- Builds Next.js webapp
- Uploads
webapp/.next/artifacts
- Downloads artifacts
- Runs
scripts/validate-build.sh - Verifies all required files exist
- Runs
npm audit --production --audit-level=high - Non-blocking but logged
- Aggregates all job results
- Creates GitHub step summary
- Fails if critical jobs failed
Timeout: 10-15 minutes per job
File: .github/workflows/gxq-pr-check.yml
Triggers:
- Pull requests to
masterormain - Only runs if PR is not draft
Purpose: Validate PR changes before merge
Features:
- Full validation pipeline (env, lint, typecheck, build)
- Calculates and reports artifact sizes
- Posts automated comment to PR with results
- Security scanning
PR Comment Format:
## 🔍 GXQ PR Check Results
✅ **All validation checks passed!**
### Build Artifacts
| Component | Size |
|-----------|------|
| Backend (dist/) | 15MB |
| Webapp (.next/) | 42MB |
### Checks Performed
- ✅ Environment validation
- ✅ Dependency installation
- ✅ Linting (warnings allowed)
- ✅ Type checking
- ✅ Backend build
- ✅ Webapp build
- ✅ Build artifact validation
---
*Ready for review and merge* 🚀File: .github/workflows/gxq-deploy-production.yml
Triggers:
- Manual workflow dispatch with
deploy_targetchoice (all/vercel/railway) - Push to tags matching
v*pattern
Purpose: Deploy to production environments
Jobs:
- Installs all dependencies
- Builds backend and webapp
- Validates artifacts
- Uploads for deployment jobs
- Runs
scripts/deploy-vercel.sh - Requires
VERCEL_TOKENsecret - Sets environment:
production-vercel
- Downloads backend artifacts
- Installs Railway CLI
- Deploys with
railway up - Requires
RAILWAY_TOKENsecret - Sets environment:
production-railway
- Waits 30 seconds for stabilization
- Checks Vercel health endpoint
- Checks Railway health endpoint
- Reports status
- Sends Slack notification (if
SLACK_WEBHOOK_URLconfigured) - Creates deployment summary
Required Secrets:
VERCEL_TOKENVERCEL_ORG_ID(optional)VERCEL_PROJECT_ID(optional)RAILWAY_TOKENVERCEL_PRODUCTION_URL(optional)RAILWAY_PRODUCTION_URL(optional)SLACK_WEBHOOK_URL(optional)
File: .github/workflows/gxq-scheduled-health.yml
Triggers:
- Cron schedule: Every 6 hours (
0 */6 * * *) - Manual workflow dispatch
Purpose: Monitor production services and alert on issues
Features:
- Checks Vercel (webapp) health
- Checks Railway (backend) health endpoint
- Checks Solana RPC endpoint
- Generates health report
- Creates GitHub issue if any service is unhealthy
- Auto-closes issues when services recover
Issue Management:
- Creates new issue with label
health-check,automated,priority-highif services down - Comments on existing issue if already open
- Closes issue and comments when all services healthy
Navigate to: Settings → Secrets and variables → Actions
| Secret | Description | How to Get |
|---|---|---|
VERCEL_TOKEN |
Vercel API token | https://vercel.com/account/tokens |
RAILWAY_TOKEN |
Railway API token | railway login then railway whoami --token |
| Secret | Description |
|---|---|
VERCEL_ORG_ID |
Vercel organization ID (from project settings) |
VERCEL_PROJECT_ID |
Vercel project ID (from project settings) |
VERCEL_PRODUCTION_URL |
Your production Vercel URL |
RAILWAY_PRODUCTION_URL |
Your production Railway URL |
SLACK_WEBHOOK_URL |
Slack webhook for notifications |
DISCORD_WEBHOOK_URL |
Discord webhook for notifications |
NEXT_PUBLIC_RPC_URL |
Public Solana RPC URL for builds |
-
Get Vercel Token
# Visit https://vercel.com/account/tokens # Create new token with appropriate scopes
-
Add to GitHub Secrets
- Name:
VERCEL_TOKEN - Value: Your token from step 1
- Name:
-
Optional: Link Project
- Run
vercel linkin your repo - Add org and project IDs to secrets
- Run
-
Install Railway CLI
npm install -g @railway/cli
-
Login and Get Token
railway login railway whoami --token
-
Add to GitHub Secrets
- Name:
RAILWAY_TOKEN - Value: Token from step 2
- Name:
-
Configure railway.json
- Ensure
railway.jsonexists in repo root - Configure services and environment
- Ensure
Option 1: Via GitHub Actions
- Go to Actions tab
- Select GXQ Deploy Production
- Click Run workflow
- Choose
deploy_target: vercel - Click Run workflow
Option 2: Via Command Line
npm run deploy:vercelOption 3: Via Git Tag
git tag v2025.01.15-1200
git push origin v2025.01.15-1200Option 1: Via GitHub Actions
- Go to Actions tab
- Select GXQ Deploy Production
- Click Run workflow
- Choose
deploy_target: railway - Click Run workflow
Option 2: Via Command Line
npm run deploy:railwayOption 1: Via GitHub Actions
- Go to Actions tab
- Select GXQ Deploy Production
- Click Run workflow
- Choose
deploy_target: all - Click Run workflow
Option 2: Via Master Orchestrator
npm run master # Prepare everything
npm run deploy:vercel # Deploy webapp
npm run deploy:railway # Deploy backend
npm run health # VerifyVia Dashboard:
- Go to https://vercel.com/dashboard
- Select your project
- Go to Deployments tab
- Find previous working deployment
- Click ⋮ → Promote to Production
Via CLI:
vercel rollback [deployment-url]Via Dashboard:
- Go to Railway dashboard
- Select your project
- Go to Deployments
- Click on previous working deployment
- Click Redeploy
Via CLI:
railway rollback [deployment-id]If both services need rollback:
# Find last working commit
git log --oneline
# Create rollback commit
git revert [bad-commit-hash]
# Or reset (destructive)
git reset --hard [last-good-commit]
git push --force origin masterThe system automatically:
- Checks service health every 6 hours
- Creates GitHub issues for failures
- Auto-closes issues when recovered
npm run healthVercel:
vercel logs --follow
# Or via dashboard: https://vercel.com/dashboardRailway:
railway logs --follow
# Or via dashboard: railway.appLocal Aggregation:
npm run logs all # All logs
npm run logs backend # Backend only
npm run logs webapp # Webapp onlyGenerate performance report:
npm run perfView reports in reports/ directory:
performance-YYYY-MM-DD.mdmetrics.json
Symptoms: install-dependencies job fails
Solution:
- Check
package-lock.jsonis committed - Clear npm cache:
npm cache clean --force rm -rf node_modules package-lock.json npm install git add package-lock.json git commit -m "fix: Update package-lock.json"
Symptoms: build-backend or build-webapp fails in CI
Solution:
- Check Node.js version matches (20.x)
- Verify TypeScript errors:
npm run type-check npm run type-check:webapp
- Check for missing environment variables in workflow
Symptoms: Deploy jobs fail with authentication error
Solution:
- Verify secret is set in GitHub: Settings → Secrets
- Check token hasn't expired
- Regenerate token and update secret
Symptoms: Health check workflow reports services down when they're actually up
Solution:
- Verify URLs in secrets are correct
- Check services are actually accessible
- Adjust timeout in workflow if services are slow to respond
Symptoms: PR opened but no check runs
Solution:
- Ensure PR is not in draft state
- Check workflow file is in
.github/workflows/ - Verify workflow has correct trigger configuration
Use conventional commits for clarity:
feat: Add new feature
fix: Bug fix
docs: Documentation update
chore: Maintenance task
ci: CI/CD changes
master/main: Production-ready code onlydevelop: Integration branchfeature/*: Feature brancheshotfix/*: Emergency fixes
- Create feature branch
- Make changes
- Open PR to
master - Wait for GXQ PR Check to pass
- Request review
- Merge when approved
- GXQ Master CI runs automatically
- Deploy via workflow dispatch or tag
- Development: Continuous (every merge to develop)
- Staging: Daily or per feature completion
- Production: Weekly or on-demand via workflow dispatch
- Automated: Every 6 hours via scheduled workflow
- Manual: Daily via
npm run health - Performance: Weekly via
npm run perf
- Create Slack webhook: https://api.slack.com/messaging/webhooks
- Add
SLACK_WEBHOOK_URLto GitHub secrets - Notifications sent automatically on deployments
Similar to Slack:
- Create Discord webhook in server settings
- Add
DISCORD_WEBHOOK_URLto GitHub secrets - Modify workflow to use Discord action
To integrate with statuspage.io or similar:
- Add API key to secrets
- Modify health check workflow to post updates
- Use their API to update component status
- Edit workflow files in
.github/workflows/ - Test in feature branch first
- Monitor first few runs after merge
- Rollback if issues arise
- Edit scripts in
scripts/ - Test locally first:
bash scripts/script-name.sh - Update documentation if behavior changes
- Commit and push
Use Dependabot or Renovate:
- Enable in repository settings
- Review and merge dependency PRs
- Monitor CI after merges
- Never commit secrets to repository
- Use GitHub Secrets for sensitive data
- Rotate tokens regularly (quarterly)
- Review npm audit results in CI
- Enable branch protection on master/main
- Require PR reviews before merge
- Enable signed commits for added security
- Documentation: See
SMART_BRAIN_OPERATOR.mdfor script details - Issues: Report at https://github.com/SMSDAO/TradeOS/issues
- Discussions: Use GitHub Discussions for questions
- Initial CI/CD infrastructure
- Four GitHub Actions workflows
- Automated health monitoring
- Deployment automation
- Performance reporting
Last updated: 2025-01-01