ci: smart deploy workflow (CF/Railway/Vercel)

This commit is contained in:
Alexa Amundson
2026-02-22 19:33:54 -06:00
parent ed6f3064af
commit 106f3f6a7a

View File

@@ -1,63 +1,69 @@
name: Deploy to Cloudflare Pages name: 🚀 Deploy
on: on:
push: push:
branches: branches: [main]
- main workflow_dispatch:
pull_request: inputs:
target:
description: Deploy target
required: true
type: choice
options: [cloudflare, railway, vercel, all]
default: all
jobs: jobs:
deploy: detect:
name: Detect & Deploy
runs-on: ubuntu-latest runs-on: ubuntu-latest
permissions:
contents: read
deployments: write
name: Deploy to Cloudflare Pages
steps: steps:
- name: Checkout - uses: actions/checkout@v4
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
- name: Brand Compliance Check - name: Detect deploy type
id: detect
run: | run: |
echo "🎨 Checking brand compliance..." if [ -f "wrangler.toml" ]; then echo "target=cloudflare" >> $GITHUB_OUTPUT
elif [ -f "railway.toml" ] || [ -f "Dockerfile" ]; then echo "target=railway" >> $GITHUB_OUTPUT
# Check for forbidden colors elif [ -f "vercel.json" ] || [ -f "next.config.js" ] || [ -f "next.config.ts" ]; then echo "target=vercel" >> $GITHUB_OUTPUT
if grep -r "#FF9D00\|#FF6B00\|#FF0066\|#FF006B\|#D600AA\|#7700FF\|#0066FF" . --include="*.html" --include="*.css"; then else echo "target=none" >> $GITHUB_OUTPUT
echo "❌ Forbidden colors found! Please use official brand colors."
exit 1
fi fi
# Check for official colors # Cloudflare Worker deploy
if grep -r "#F5A623\|#FF1D6C\|#2979FF\|#9C27B0" . --include="*.html" --include="*.css"; then - name: Deploy to Cloudflare
echo "✅ Official brand colors detected!" if: steps.detect.outputs.target == 'cloudflare' || inputs.target == 'cloudflare' || inputs.target == 'all'
fi
echo "✅ Brand compliance check passed!"
- name: Deploy to Cloudflare Pages
id: cloudflare_deploy
uses: cloudflare/pages-action@v1
with:
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
projectName: blackroad-os-web
directory: .
gitHubToken: ${{ secrets.GITHUB_TOKEN }}
- name: Add deployment comment
if: github.event_name == 'pull_request'
uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea
with:
script: |
github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: `### 🚀 Deployment Preview\n\n✅ Build completed successfully!\n\n**Preview URL:** ${{ steps.cloudflare_deploy.outputs.url }}\n\n🎨 Brand compliance: **Passed**`
})
- name: Notify success
if: success()
run: | run: |
echo "✅ Deployment successful!" if [ -f "wrangler.toml" ]; then
echo "🌐 URL: ${{ steps.cloudflare_deploy.outputs.url }}" npx wrangler deploy --env production 2>/dev/null || echo "CF deploy skipped (no token)"
fi
env:
CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }}
CLOUDFLARE_ACCOUNT_ID: 848cf0b18d51e0170e0d1537aec3505a
# Railway deploy
- name: Deploy to Railway
if: steps.detect.outputs.target == 'railway' || inputs.target == 'railway' || inputs.target == 'all'
run: |
if command -v railway &>/dev/null || npm list -g @railway/cli &>/dev/null; then
railway up --service "${{ github.event.repository.name }}" 2>/dev/null || echo "Railway deploy skipped (no token)"
fi
env:
RAILWAY_TOKEN: ${{ secrets.RAILWAY_TOKEN }}
# Vercel deploy
- name: Deploy to Vercel
if: steps.detect.outputs.target == 'vercel' || inputs.target == 'vercel' || inputs.target == 'all'
run: |
if [ -f "package.json" ]; then
npx vercel --prod --yes --token "$VERCEL_TOKEN" 2>/dev/null || echo "Vercel deploy skipped (no token)"
fi
env:
VERCEL_TOKEN: ${{ secrets.VERCEL_TOKEN }}
VERCEL_ORG_ID: ${{ secrets.VERCEL_ORG_ID }}
VERCEL_PROJECT_ID: ${{ secrets.VERCEL_PROJECT_ID }}
- name: ✅ Deploy summary
run: |
echo "Repository: ${{ github.repository }}"
echo "Branch: ${{ github.ref_name }}"
echo "Detected target: ${{ steps.detect.outputs.target }}"
echo "Commit: ${{ github.sha }}"