-
Notifications
You must be signed in to change notification settings - Fork 9
150 lines (134 loc) Β· 4.53 KB
/
prod.docs.plus.yml
File metadata and controls
150 lines (134 loc) Β· 4.53 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
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
# Production CI/CD Pipeline for docs.plus
name: CI-Production
# Triggered on push or pull request to main branch
on:
push:
branches: [main]
pull_request:
branches: [main]
jobs:
# ============================================================
# UPTIME KUMA - Independent pipeline (no dependencies)
# ============================================================
build-uptime-kuma:
name: π Deploy Uptime Kuma
runs-on: prod.docs.plus
if: contains(github.event.head_commit.message, 'build') && contains(github.event.head_commit.message, 'uptime-kuma')
steps:
- name: π¦ Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 1
clean: false
- name: π Deploy Uptime Kuma
run: make build_uptime_kuma
# ============================================================
# FRONTEND - Build and deploy Next.js app with PM2
# ============================================================
build-front:
name: π¨ Deploy Frontend
runs-on: prod.docs.plus
if: contains(github.event.head_commit.message, 'build') && contains(github.event.head_commit.message, 'front')
steps:
- name: π¦ Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 1
clean: false
- name: π₯ Setup Bun
uses: oven-sh/setup-bun@v2
with:
bun-version: latest
- name: π₯ Install dependencies
run: bun install --frozen-lockfile
- name: π Ensure .env exists
run: |
if [ -f "../../../.env" ]; then
cp ../../../.env packages/webapp/.env
elif [ -f "../../.env" ]; then
cp ../../.env packages/webapp/.env
elif [ -f ".env" ]; then
cp .env packages/webapp/.env
fi
continue-on-error: true
- name: π Build & Deploy Frontend
run: make build_front_production
- name: π©Ί Health check
run: |
echo "β³ Waiting for app to be ready..."
sleep 15
curl -f http://localhost:3001/api/health || (echo "β Health check failed" && exit 1)
echo "β
Frontend is healthy!"
# ============================================================
# BACKEND - Build and deploy Hocuspocus server with Docker
# ============================================================
build-back:
name: π§ Deploy Backend
runs-on: prod.docs.plus
if: contains(github.event.head_commit.message, 'build') && contains(github.event.head_commit.message, 'back')
steps:
- name: π¦ Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 1
clean: false
- name: π₯ Setup Bun
uses: oven-sh/setup-bun@v2
with:
bun-version: latest
- name: π₯ Install dependencies
run: bun install --frozen-lockfile
- name: π Ensure .env is available
run: |
if [ -f "../../../.env" ]; then
cp ../../../.env packages/hocuspocus.server/.env
elif [ -f "../../.env" ]; then
cp ../../.env packages/hocuspocus.server/.env
elif [ -f ".env" ]; then
cp .env packages/hocuspocus.server/.env
fi
continue-on-error: true
- name: π³ Build & Deploy Backend
run: make build_hocuspocus.server_prod
env:
DATABASE_URL: ${{ secrets.STAGE_DATABASE_URL }}
- name: π Check containers
run: |
echo "π Checking running containers..."
docker ps | grep prod-docsplus || echo "β οΈ Warning: No prod-docsplus containers found"
echo "β
Backend deployment completed!"
# ============================================================
# π USAGE EXAMPLES
# ============================================================
#
# Trigger specific pipelines by including keywords in commit messages:
#
# 1οΈβ£ Frontend only:
# git commit -m "Feature: New UI component (build front)"
#
# 2οΈβ£ Backend only:
# git commit -m "Fix: WebSocket connection (build back)"
#
# 3οΈβ£ Uptime Kuma only:
# git commit -m "Update monitoring (build uptime-kuma)"
#
# 4οΈβ£ Frontend + Backend:
# git commit -m "Full deploy (build front back)"
#
# 5οΈβ£ Everything at once:
# git commit -m "Major release (build front back uptime-kuma)"
#
# Then push to main:
# git push origin main
#
# ============================================================
# π PIPELINE LOGIC
# ============================================================
#
# - All jobs are independent and self-contained
# - Each job installs Bun and dependencies
# - .env files are preserved during deployment
# - Health checks ensure successful deployments
# - No shared state between jobs (simpler and more reliable)
#
# ============================================================