Skip to content

Add multi-provider sourcing: Proxycurl -> Apollo -> Apify cascade #30

Add multi-provider sourcing: Proxycurl -> Apollo -> Apify cascade

Add multi-provider sourcing: Proxycurl -> Apollo -> Apify cascade #30

Workflow file for this run

name: Deploy
on:
push:
branches: [main]
workflow_dispatch:
inputs:
environment:
description: "Deployment environment"
required: true
default: "production"
type: choice
options:
- production
- staging
env:
PYTHON_VERSION: "3.11"
NODE_VERSION: "20"
jobs:
# Run tests before deployment
test:
name: Pre-deployment Tests
uses: ./.github/workflows/ci.yml
secrets: inherit
# Deploy Frontend to Vercel
deploy-frontend:
name: Deploy Frontend to Vercel
needs: test
runs-on: ubuntu-latest
environment:
name: ${{ github.event.inputs.environment || 'production' }}
url: ${{ steps.deploy.outputs.url }}
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_VERSION }}
- name: Install Vercel CLI
run: npm install -g vercel@latest
- name: Pull Vercel Environment
run: vercel pull --yes --environment=production --token=${{ secrets.VERCEL_TOKEN }}
working-directory: frontend
- name: Build Project
run: vercel build --prod --token=${{ secrets.VERCEL_TOKEN }}
working-directory: frontend
env:
NEXT_PUBLIC_SUPABASE_URL: ${{ secrets.NEXT_PUBLIC_SUPABASE_URL }}
NEXT_PUBLIC_SUPABASE_ANON_KEY: ${{ secrets.NEXT_PUBLIC_SUPABASE_ANON_KEY }}
NEXT_PUBLIC_API_URL: ${{ secrets.NEXT_PUBLIC_API_URL }}
- name: Deploy to Vercel
id: deploy
run: |
url=$(vercel deploy --prebuilt --prod --token=${{ secrets.VERCEL_TOKEN }})
echo "url=$url" >> $GITHUB_OUTPUT
working-directory: frontend
- name: Comment deployment URL
if: github.event_name == 'pull_request'
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: `Frontend deployed to: ${{ steps.deploy.outputs.url }}`
})
# Deploy Backend to Railway
deploy-backend:
name: Deploy Backend to Railway
needs: test
runs-on: ubuntu-latest
environment:
name: ${{ github.event.inputs.environment || 'production' }}
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Install Railway CLI
run: npm install -g @railway/cli
- name: Deploy to Railway
run: railway up --service backend
working-directory: backend
env:
RAILWAY_TOKEN: ${{ secrets.RAILWAY_TOKEN }}
- name: Verify deployment health
run: |
# Wait for deployment to be ready
sleep 30
# Health check (replace with your actual API URL)
if [ -n "${{ secrets.BACKEND_URL }}" ]; then
response=$(curl -s -o /dev/null -w "%{http_code}" "${{ secrets.BACKEND_URL }}/health" || echo "000")
if [ "$response" != "200" ]; then
echo "Health check failed with status: $response"
exit 1
fi
echo "Backend health check passed!"
else
echo "BACKEND_URL not set, skipping health check"
fi
# Database migrations (optional, run manually)
migrate-database:
name: Run Database Migrations
needs: [deploy-backend]
runs-on: ubuntu-latest
if: github.event_name == 'workflow_dispatch'
environment:
name: ${{ github.event.inputs.environment || 'production' }}
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup Supabase CLI
uses: supabase/setup-cli@v1
with:
version: latest
- name: Run migrations
run: |
supabase db push --linked
env:
SUPABASE_ACCESS_TOKEN: ${{ secrets.SUPABASE_ACCESS_TOKEN }}
# Deployment summary
deployment-summary:
name: Deployment Summary
needs: [deploy-frontend, deploy-backend]
runs-on: ubuntu-latest
if: always()
steps:
- name: Check deployment status
run: |
echo "=== Deployment Summary ==="
echo "Frontend: ${{ needs.deploy-frontend.result }}"
echo "Backend: ${{ needs.deploy-backend.result }}"
if [[ "${{ needs.deploy-frontend.result }}" != "success" ]] || \
[[ "${{ needs.deploy-backend.result }}" != "success" ]]; then
echo "One or more deployments failed!"
exit 1
fi
echo "All deployments completed successfully!"
- name: Send notification
if: failure()
uses: actions/github-script@v7
with:
script: |
// Create an issue for failed deployment
await github.rest.issues.create({
owner: context.repo.owner,
repo: context.repo.repo,
title: `Deployment failed - ${new Date().toISOString().split('T')[0]}`,
body: `Deployment failed for commit ${context.sha}.\n\nWorkflow run: ${context.serverUrl}/${context.repo.owner}/${context.repo.repo}/actions/runs/${context.runId}`,
labels: ['deployment', 'bug']
});