70 lines
2.5 KiB
YAML
70 lines
2.5 KiB
YAML
name: 🚀 Deploy
|
|
|
|
on:
|
|
push:
|
|
branches: [main]
|
|
workflow_dispatch:
|
|
inputs:
|
|
target:
|
|
description: Deploy target
|
|
required: true
|
|
type: choice
|
|
options: [cloudflare, railway, vercel, all]
|
|
default: all
|
|
|
|
jobs:
|
|
detect:
|
|
name: Detect & Deploy
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
|
|
- name: Detect deploy type
|
|
id: detect
|
|
run: |
|
|
if [ -f "wrangler.toml" ]; then echo "target=cloudflare" >> $GITHUB_OUTPUT
|
|
elif [ -f "railway.toml" ] || [ -f "Dockerfile" ]; then echo "target=railway" >> $GITHUB_OUTPUT
|
|
elif [ -f "vercel.json" ] || [ -f "next.config.js" ] || [ -f "next.config.ts" ]; then echo "target=vercel" >> $GITHUB_OUTPUT
|
|
else echo "target=none" >> $GITHUB_OUTPUT
|
|
fi
|
|
|
|
# Cloudflare Worker deploy
|
|
- name: Deploy to Cloudflare
|
|
if: steps.detect.outputs.target == 'cloudflare' || inputs.target == 'cloudflare' || inputs.target == 'all'
|
|
run: |
|
|
if [ -f "wrangler.toml" ]; then
|
|
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 }}"
|