This repository was archived by the owner on Mar 9, 2026. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
115 lines (95 loc) · 3.34 KB
/
auto-deploy.yml
File metadata and controls
115 lines (95 loc) · 3.34 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
name: 🚀 Auto Deploy
on:
push:
branches: [main, master]
workflow_dispatch:
env:
NODE_VERSION: '20'
jobs:
detect-service:
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
needs: detect-service
if: needs.detect-service.outputs.deploy_target == 'cloudflare'
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v6
- name: Setup Node
uses: actions/setup-node@v6
with:
node-version: ${{ env.NODE_VERSION }}
cache: 'npm'
- name: Install Dependencies
run: npm ci
- name: Build
run: npm run build
env:
NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY: ${{ secrets.NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY }}
- name: Deploy to Cloudflare Pages
uses: cloudflare/wrangler-action@v3
with:
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
command: pages deploy .next --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