mirror of
https://github.com/blackboxprogramming/blackroad-apps.git
synced 2026-03-17 08:57:13 -05:00
fix: replace Railway with Cloudflare Pages deploy
This commit is contained in:
106
.github/workflows/auto-deploy.yml
vendored
106
.github/workflows/auto-deploy.yml
vendored
@@ -1,115 +1,33 @@
|
|||||||
name: 🚀 Auto Deploy
|
name: "🚀 Auto Deploy"
|
||||||
|
|
||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
branches: [main, master]
|
branches: [main, master]
|
||||||
workflow_dispatch:
|
workflow_dispatch:
|
||||||
|
|
||||||
env:
|
|
||||||
NODE_VERSION: '20'
|
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
detect-service:
|
deploy:
|
||||||
name: Detect Service Type
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
outputs:
|
|
||||||
service_type: ${{ steps.detect.outputs.service_type }}
|
|
||||||
deploy_target: ${{ steps.detect.outputs.deploy_target }}
|
|
||||||
|
|
||||||
steps:
|
|
||||||
- name: Checkout
|
|
||||||
uses: actions/checkout@v6
|
|
||||||
|
|
||||||
- name: Detect Service Type
|
|
||||||
id: detect
|
|
||||||
run: |
|
|
||||||
if [ -f "next.config.mjs" ] || [ -f "next.config.js" ]; then
|
|
||||||
echo "service_type=nextjs" >> $GITHUB_OUTPUT
|
|
||||||
echo "deploy_target=cloudflare" >> $GITHUB_OUTPUT
|
|
||||||
elif [ -f "Dockerfile" ]; then
|
|
||||||
echo "service_type=docker" >> $GITHUB_OUTPUT
|
|
||||||
echo "deploy_target=railway" >> $GITHUB_OUTPUT
|
|
||||||
elif [ -f "package.json" ]; then
|
|
||||||
echo "service_type=node" >> $GITHUB_OUTPUT
|
|
||||||
echo "deploy_target=railway" >> $GITHUB_OUTPUT
|
|
||||||
elif [ -f "requirements.txt" ]; then
|
|
||||||
echo "service_type=python" >> $GITHUB_OUTPUT
|
|
||||||
echo "deploy_target=railway" >> $GITHUB_OUTPUT
|
|
||||||
else
|
|
||||||
echo "service_type=static" >> $GITHUB_OUTPUT
|
|
||||||
echo "deploy_target=cloudflare" >> $GITHUB_OUTPUT
|
|
||||||
fi
|
|
||||||
|
|
||||||
deploy-cloudflare:
|
|
||||||
name: Deploy to Cloudflare Pages
|
name: Deploy to Cloudflare Pages
|
||||||
needs: detect-service
|
|
||||||
if: needs.detect-service.outputs.deploy_target == 'cloudflare'
|
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v6
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
- name: Setup Node
|
- name: Setup Node
|
||||||
uses: actions/setup-node@v6
|
uses: actions/setup-node@v4
|
||||||
with:
|
with:
|
||||||
node-version: ${{ env.NODE_VERSION }}
|
node-version: '20'
|
||||||
cache: 'npm'
|
|
||||||
|
|
||||||
- name: Install Dependencies
|
- name: Install & Build
|
||||||
run: npm ci
|
run: |
|
||||||
|
if [ -f "package.json" ]; then
|
||||||
- name: Build
|
npm install
|
||||||
run: npm run build
|
npm run build 2>/dev/null || true
|
||||||
env:
|
fi
|
||||||
NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY: ${{ secrets.NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY }}
|
|
||||||
|
|
||||||
- name: Deploy to Cloudflare Pages
|
- name: Deploy to Cloudflare Pages
|
||||||
uses: cloudflare/wrangler-action@v3
|
uses: cloudflare/wrangler-action@v3
|
||||||
with:
|
with:
|
||||||
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
|
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
|
||||||
accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
|
accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
|
||||||
command: pages deploy .next --project-name=${{ github.event.repository.name }}
|
command: pages deploy . --project-name=${{ github.event.repository.name }}
|
||||||
|
|
||||||
deploy-railway:
|
|
||||||
name: Deploy to Railway
|
|
||||||
needs: detect-service
|
|
||||||
if: needs.detect-service.outputs.deploy_target == 'railway'
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
|
|
||||||
steps:
|
|
||||||
- name: Checkout
|
|
||||||
uses: actions/checkout@v6
|
|
||||||
|
|
||||||
- name: Install Railway CLI
|
|
||||||
run: npm i -g @railway/cli
|
|
||||||
|
|
||||||
- name: Deploy to Railway
|
|
||||||
run: railway up --service ${{ github.event.repository.name }}
|
|
||||||
env:
|
|
||||||
RAILWAY_TOKEN: ${{ secrets.RAILWAY_TOKEN }}
|
|
||||||
|
|
||||||
health-check:
|
|
||||||
name: Health Check
|
|
||||||
needs: [deploy-cloudflare, deploy-railway]
|
|
||||||
if: always() && (needs.deploy-cloudflare.result == 'success' || needs.deploy-railway.result == 'success')
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
|
|
||||||
steps:
|
|
||||||
- name: Wait for Deployment
|
|
||||||
run: sleep 30
|
|
||||||
|
|
||||||
- name: Check Health Endpoint
|
|
||||||
run: |
|
|
||||||
URL="${{ secrets.DEPLOY_URL }}/api/health"
|
|
||||||
curl -f $URL || exit 1
|
|
||||||
|
|
||||||
- name: Notify Success
|
|
||||||
if: success()
|
|
||||||
run: echo "✅ Deployment successful and healthy!"
|
|
||||||
|
|
||||||
- name: Notify Failure
|
|
||||||
if: failure()
|
|
||||||
run: |
|
|
||||||
echo "❌ Deployment health check failed!"
|
|
||||||
exit 1
|
|
||||||
|
|||||||
Reference in New Issue
Block a user