myaidev-method 0.2.4 → 0.2.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/USER_GUIDE.md +389 -8
- package/bin/cli.js +165 -30
- package/package.json +1 -1
- package/src/lib/ascii-banner.js +100 -0
- package/src/templates/claude/commands/myai-deploy-dev.md +500 -0
- package/src/templates/claude/commands/myai-deploy-prod.md +837 -0
- package/src/templates/claude/commands/myai-deploy-staging.md +331 -0
- package/src/templates/claude/commands/myai-git-hotfix.md +957 -0
- package/src/templates/claude/commands/myai-git-pr.md +200 -0
- package/src/templates/claude/commands/myai-git-release.md +806 -0
- package/src/templates/claude/commands/myai-git-sync.md +796 -0
- package/src/templates/codex/commands/myai-astro-publish.md +51 -0
- package/src/templates/codex/commands/myai-configure.md +185 -0
- package/src/templates/codex/commands/myai-content-writer.md +73 -0
- package/src/templates/codex/commands/myai-coolify-deploy.md +159 -0
- package/src/templates/codex/commands/myai-deploy-dev.md +379 -0
- package/src/templates/codex/commands/myai-deploy-prod.md +431 -0
- package/src/templates/codex/commands/myai-deploy-staging.md +275 -0
- package/src/templates/codex/commands/myai-dev-architect.md +69 -0
- package/src/templates/codex/commands/myai-dev-code.md +82 -0
- package/src/templates/codex/commands/myai-dev-docs.md +83 -0
- package/src/templates/codex/commands/myai-dev-review.md +85 -0
- package/src/templates/codex/commands/myai-dev-test.md +84 -0
- package/src/templates/codex/commands/myai-docusaurus-publish.md +42 -0
- package/src/templates/codex/commands/myai-git-hotfix.md +512 -0
- package/src/templates/codex/commands/myai-git-pr.md +196 -0
- package/src/templates/codex/commands/myai-git-release.md +516 -0
- package/src/templates/codex/commands/myai-git-sync.md +517 -0
- package/src/templates/codex/commands/myai-mintlify-publish.md +42 -0
- package/src/templates/codex/commands/myai-payloadcms-publish.md +42 -0
- package/src/templates/codex/commands/myai-sparc-workflow.md +185 -0
- package/src/templates/codex/commands/myai-wordpress-admin.md +143 -0
- package/src/templates/codex/commands/myai-wordpress-publish.md +66 -0
- package/src/templates/gemini/commands/myai-astro-publish.toml +76 -0
- package/src/templates/gemini/commands/myai-configure.toml +188 -0
- package/src/templates/gemini/commands/myai-content-writer.toml +76 -0
- package/src/templates/gemini/commands/myai-coolify-deploy.toml +138 -0
- package/src/templates/gemini/commands/myai-deploy-dev.toml +379 -0
- package/src/templates/gemini/commands/myai-deploy-prod.toml +438 -0
- package/src/templates/gemini/commands/myai-deploy-staging.toml +275 -0
- package/src/templates/gemini/commands/myai-dev-architect.toml +64 -0
- package/src/templates/gemini/commands/myai-dev-code.toml +75 -0
- package/src/templates/gemini/commands/myai-dev-docs.toml +76 -0
- package/src/templates/gemini/commands/myai-dev-review.toml +78 -0
- package/src/templates/gemini/commands/myai-dev-test.toml +77 -0
- package/src/templates/gemini/commands/myai-docusaurus-publish.toml +63 -0
- package/src/templates/gemini/commands/myai-git-hotfix.toml +953 -0
- package/src/templates/gemini/commands/myai-git-pr.toml +196 -0
- package/src/templates/gemini/commands/myai-git-release.toml +802 -0
- package/src/templates/gemini/commands/myai-git-sync.toml +792 -0
- package/src/templates/gemini/commands/myai-mintlify-publish.toml +67 -0
- package/src/templates/gemini/commands/myai-payloadcms-publish.toml +59 -0
- package/src/templates/gemini/commands/myai-sparc-workflow.toml +47 -0
- package/src/templates/gemini/commands/myai-wordpress-admin.toml +143 -0
- package/src/templates/gemini/commands/myai-wordpress-publish.toml +77 -0
|
@@ -0,0 +1,953 @@
|
|
|
1
|
+
prompt = """
|
|
2
|
+
|
|
3
|
+
Task: Create and deploy hotfix - {{args}}
|
|
4
|
+
|
|
5
|
+
## Hotfix Workflow
|
|
6
|
+
|
|
7
|
+
### 1. Emergency Assessment
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
assess_hotfix_urgency() {
|
|
11
|
+
echo \"🚨 HOTFIX EMERGENCY ASSESSMENT\"
|
|
12
|
+
echo \"═══════════════════════════════════════\"
|
|
13
|
+
|
|
14
|
+
# Gather incident information
|
|
15
|
+
read -p \"Issue description: \" issue_desc
|
|
16
|
+
read -p \"Severity (critical/high/medium): \" severity
|
|
17
|
+
read -p \"Affected systems: \" affected_systems
|
|
18
|
+
read -p \"User impact: \" user_impact
|
|
19
|
+
|
|
20
|
+
# Create incident record
|
|
21
|
+
incident_id=\"HOTFIX-$(date +%Y%m%d-%H%M%S)\"
|
|
22
|
+
|
|
23
|
+
cat > \".hotfix-$incident_id.json\" << EOF
|
|
24
|
+
{
|
|
25
|
+
\"incident_id\": \"$incident_id\",
|
|
26
|
+
\"timestamp\": \"$(date -u +%Y-%m-%dT%H:%M:%SZ)\",
|
|
27
|
+
\"severity\": \"$severity\",
|
|
28
|
+
\"description\": \"$issue_desc\",
|
|
29
|
+
\"affected_systems\": \"$affected_systems\",
|
|
30
|
+
\"user_impact\": \"$user_impact\",
|
|
31
|
+
\"status\": \"initiated\"
|
|
32
|
+
}
|
|
33
|
+
EOF
|
|
34
|
+
|
|
35
|
+
echo \"\"
|
|
36
|
+
echo \"╔══════════════════════════════════════════════════════════╗\"
|
|
37
|
+
echo \"║ HOTFIX INCIDENT CREATED ║\"
|
|
38
|
+
echo \"╚══════════════════════════════════════════════════════════╝\"
|
|
39
|
+
echo \"Incident ID: $incident_id\"
|
|
40
|
+
echo \"Severity: $severity\"
|
|
41
|
+
echo \"Description: $issue_desc\"
|
|
42
|
+
echo \"\"
|
|
43
|
+
|
|
44
|
+
# Alert team
|
|
45
|
+
send_hotfix_alert \"$incident_id\" \"initiated\" \"$severity\" \"$issue_desc\"
|
|
46
|
+
|
|
47
|
+
echo \"$incident_id\"
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
# Create incident
|
|
51
|
+
incident_id=$(assess_hotfix_urgency)
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
### 2. Create Hotfix Branch from Production
|
|
55
|
+
|
|
56
|
+
```bash
|
|
57
|
+
create_hotfix_branch() {
|
|
58
|
+
local incident_id=$1
|
|
59
|
+
local hotfix_branch=\"hotfix/$incident_id\"
|
|
60
|
+
|
|
61
|
+
echo \"🔧 Creating hotfix branch from production...\"
|
|
62
|
+
|
|
63
|
+
# Fetch latest
|
|
64
|
+
git fetch --all
|
|
65
|
+
|
|
66
|
+
# Determine production branch/tag
|
|
67
|
+
if git show-ref --verify --quiet refs/heads/production; then
|
|
68
|
+
base_branch=\"production\"
|
|
69
|
+
elif git show-ref --verify --quiet refs/heads/main; then
|
|
70
|
+
base_branch=\"main\"
|
|
71
|
+
else
|
|
72
|
+
base_branch=\"master\"
|
|
73
|
+
fi
|
|
74
|
+
|
|
75
|
+
# Get production tag (most recent release)
|
|
76
|
+
latest_prod_tag=$(git tag --sort=-creatordate | grep -E \"^v[0-9]+\\.[0-9]+\\.[0-9]+$\" | head -1)
|
|
77
|
+
|
|
78
|
+
if [ -n \"$latest_prod_tag\" ]; then
|
|
79
|
+
echo \"🏷️ Creating hotfix from production tag: $latest_prod_tag\"
|
|
80
|
+
base_ref=\"$latest_prod_tag\"
|
|
81
|
+
else
|
|
82
|
+
echo \"📍 Creating hotfix from $base_branch branch\"
|
|
83
|
+
base_ref=\"origin/$base_branch\"
|
|
84
|
+
fi
|
|
85
|
+
|
|
86
|
+
# Create hotfix branch
|
|
87
|
+
git checkout -b \"$hotfix_branch\" \"$base_ref\" || {
|
|
88
|
+
echo \"❌ Failed to create hotfix branch\"
|
|
89
|
+
exit 1
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
echo \"✅ Hotfix branch created: $hotfix_branch\"
|
|
93
|
+
echo \"📍 Base: $base_ref\"
|
|
94
|
+
|
|
95
|
+
# Update incident record
|
|
96
|
+
jq \".hotfix_branch = \\\"$hotfix_branch\\\" | .base_ref = \\\"$base_ref\\\"\" \\
|
|
97
|
+
\".hotfix-$incident_id.json\" > temp.json && mv temp.json \".hotfix-$incident_id.json\"
|
|
98
|
+
|
|
99
|
+
echo \"$hotfix_branch\"
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
# Create hotfix branch
|
|
103
|
+
hotfix_branch=$(create_hotfix_branch \"$incident_id\")
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
### 3. Apply Hotfix (Guided)
|
|
107
|
+
|
|
108
|
+
```bash
|
|
109
|
+
apply_hotfix() {
|
|
110
|
+
local incident_id=$1
|
|
111
|
+
local hotfix_branch=$2
|
|
112
|
+
|
|
113
|
+
echo \"🔧 Applying hotfix...\"
|
|
114
|
+
echo \"\"
|
|
115
|
+
echo \"Options:\"
|
|
116
|
+
echo \" 1. Apply existing patch file\"
|
|
117
|
+
echo \" 2. Make manual code changes\"
|
|
118
|
+
echo \" 3. Cherry-pick from another branch\"
|
|
119
|
+
echo \" 4. Revert specific commit\"
|
|
120
|
+
echo \"\"
|
|
121
|
+
|
|
122
|
+
read -p \"Choose option (1-4): \" fix_option
|
|
123
|
+
|
|
124
|
+
case $fix_option in
|
|
125
|
+
1)
|
|
126
|
+
# Apply patch file
|
|
127
|
+
read -p \"Enter patch file path: \" patch_file
|
|
128
|
+
if [ -f \"$patch_file\" ]; then
|
|
129
|
+
git apply \"$patch_file\" || {
|
|
130
|
+
echo \"❌ Failed to apply patch\"
|
|
131
|
+
exit 1
|
|
132
|
+
}
|
|
133
|
+
git add -A
|
|
134
|
+
git commit -m \"hotfix: apply patch from $patch_file\"
|
|
135
|
+
else
|
|
136
|
+
echo \"❌ Patch file not found\"
|
|
137
|
+
exit 1
|
|
138
|
+
fi
|
|
139
|
+
;;
|
|
140
|
+
|
|
141
|
+
2)
|
|
142
|
+
# Manual changes
|
|
143
|
+
echo \"📝 Make your code changes now\"
|
|
144
|
+
echo \"Press Enter when ready to continue...\"
|
|
145
|
+
read
|
|
146
|
+
|
|
147
|
+
if git diff-index --quiet HEAD --; then
|
|
148
|
+
echo \"⚠️ No changes detected\"
|
|
149
|
+
exit 1
|
|
150
|
+
fi
|
|
151
|
+
|
|
152
|
+
git add -A
|
|
153
|
+
|
|
154
|
+
read -p \"Commit message: \" commit_msg
|
|
155
|
+
git commit -m \"hotfix: $commit_msg\"
|
|
156
|
+
;;
|
|
157
|
+
|
|
158
|
+
3)
|
|
159
|
+
# Cherry-pick
|
|
160
|
+
read -p \"Enter commit hash to cherry-pick: \" commit_hash
|
|
161
|
+
git cherry-pick \"$commit_hash\" || {
|
|
162
|
+
echo \"❌ Cherry-pick failed\"
|
|
163
|
+
echo \"Resolve conflicts and run: git cherry-pick --continue\"
|
|
164
|
+
exit 1
|
|
165
|
+
}
|
|
166
|
+
;;
|
|
167
|
+
|
|
168
|
+
4)
|
|
169
|
+
# Revert commit
|
|
170
|
+
read -p \"Enter commit hash to revert: \" commit_hash
|
|
171
|
+
git revert \"$commit_hash\" --no-edit || {
|
|
172
|
+
echo \"❌ Revert failed\"
|
|
173
|
+
exit 1
|
|
174
|
+
}
|
|
175
|
+
;;
|
|
176
|
+
|
|
177
|
+
*)
|
|
178
|
+
echo \"Invalid option\"
|
|
179
|
+
exit 1
|
|
180
|
+
;;
|
|
181
|
+
esac
|
|
182
|
+
|
|
183
|
+
echo \"✅ Hotfix applied\"
|
|
184
|
+
|
|
185
|
+
# Update incident record
|
|
186
|
+
jq \".status = \\\"fix_applied\\\"\" \".hotfix-$incident_id.json\" > temp.json && \\
|
|
187
|
+
mv temp.json \".hotfix-$incident_id.json\"
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
# Apply fix
|
|
191
|
+
apply_hotfix \"$incident_id\" \"$hotfix_branch\"
|
|
192
|
+
```
|
|
193
|
+
|
|
194
|
+
### 4. Fast-Track Testing
|
|
195
|
+
|
|
196
|
+
```bash
|
|
197
|
+
fast_track_testing() {
|
|
198
|
+
local incident_id=$1
|
|
199
|
+
|
|
200
|
+
echo \"🧪 Running fast-track tests...\"
|
|
201
|
+
|
|
202
|
+
# Critical tests only
|
|
203
|
+
echo \"Running critical test suite...\"
|
|
204
|
+
|
|
205
|
+
# Unit tests
|
|
206
|
+
if command -v npm &>/dev/null && grep -q \"\\\"test:critical\\\"\" package.json 2>/dev/null; then
|
|
207
|
+
npm run test:critical || {
|
|
208
|
+
echo \"❌ CRITICAL: Tests failed\"
|
|
209
|
+
exit 1
|
|
210
|
+
}
|
|
211
|
+
elif command -v npm &>/dev/null; then
|
|
212
|
+
npm test || {
|
|
213
|
+
echo \"❌ CRITICAL: Tests failed\"
|
|
214
|
+
exit 1
|
|
215
|
+
}
|
|
216
|
+
fi
|
|
217
|
+
|
|
218
|
+
# Security audit (quick)
|
|
219
|
+
if command -v npm &>/dev/null; then
|
|
220
|
+
echo \"Running security audit...\"
|
|
221
|
+
npm audit --production --audit-level=high || {
|
|
222
|
+
echo \"⚠️ Security issues detected (non-blocking)\"
|
|
223
|
+
}
|
|
224
|
+
fi
|
|
225
|
+
|
|
226
|
+
# Build test
|
|
227
|
+
echo \"Testing build...\"
|
|
228
|
+
if command -v npm &>/dev/null && grep -q \"\\\"build\\\"\" package.json 2>/dev/null; then
|
|
229
|
+
npm run build || {
|
|
230
|
+
echo \"❌ CRITICAL: Build failed\"
|
|
231
|
+
exit 1
|
|
232
|
+
}
|
|
233
|
+
fi
|
|
234
|
+
|
|
235
|
+
# Smoke test (if available)
|
|
236
|
+
if command -v npm &>/dev/null && grep -q \"\\\"test:smoke\\\"\" package.json 2>/dev/null; then
|
|
237
|
+
echo \"Running smoke tests...\"
|
|
238
|
+
npm run test:smoke || {
|
|
239
|
+
echo \"⚠️ Smoke tests failed (review required)\"
|
|
240
|
+
}
|
|
241
|
+
fi
|
|
242
|
+
|
|
243
|
+
echo \"✅ Fast-track tests passed\"
|
|
244
|
+
|
|
245
|
+
# Update incident record
|
|
246
|
+
jq \".status = \\\"tested\\\" | .tests_passed = true\" \\
|
|
247
|
+
\".hotfix-$incident_id.json\" > temp.json && mv temp.json \".hotfix-$incident_id.json\"
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
# Run tests
|
|
251
|
+
fast_track_testing \"$incident_id\"
|
|
252
|
+
```
|
|
253
|
+
|
|
254
|
+
### 5. Emergency Approval
|
|
255
|
+
|
|
256
|
+
```bash
|
|
257
|
+
request_hotfix_approval() {
|
|
258
|
+
local incident_id=$1
|
|
259
|
+
local hotfix_branch=$2
|
|
260
|
+
|
|
261
|
+
echo \"\"
|
|
262
|
+
echo \"╔══════════════════════════════════════════════════════════╗\"
|
|
263
|
+
echo \"║ 🚨 EMERGENCY HOTFIX APPROVAL 🚨 ║\"
|
|
264
|
+
echo \"╚══════════════════════════════════════════════════════════╝\"
|
|
265
|
+
echo \"\"
|
|
266
|
+
echo \"Incident ID: $incident_id\"
|
|
267
|
+
echo \"Hotfix Branch: $hotfix_branch\"
|
|
268
|
+
echo \"\"
|
|
269
|
+
|
|
270
|
+
# Show changes
|
|
271
|
+
echo \"Changes:\"
|
|
272
|
+
git diff HEAD~1 --stat
|
|
273
|
+
echo \"\"
|
|
274
|
+
|
|
275
|
+
# Show commits
|
|
276
|
+
echo \"Commits:\"
|
|
277
|
+
git log --oneline -5
|
|
278
|
+
echo \"\"
|
|
279
|
+
|
|
280
|
+
# Load incident info
|
|
281
|
+
if [ -f \".hotfix-$incident_id.json\" ]; then
|
|
282
|
+
severity=$(jq -r '.severity' \".hotfix-$incident_id.json\")
|
|
283
|
+
description=$(jq -r '.description' \".hotfix-$incident_id.json\")
|
|
284
|
+
|
|
285
|
+
echo \"Severity: $severity\"
|
|
286
|
+
echo \"Description: $description\"
|
|
287
|
+
echo \"\"
|
|
288
|
+
fi
|
|
289
|
+
|
|
290
|
+
# Require explicit approval
|
|
291
|
+
if [ \"$severity\" == \"critical\" ]; then
|
|
292
|
+
read -p \"Type 'EMERGENCY DEPLOY' to approve: \" approval
|
|
293
|
+
required_text=\"EMERGENCY DEPLOY\"
|
|
294
|
+
else
|
|
295
|
+
read -p \"Type 'DEPLOY HOTFIX' to approve: \" approval
|
|
296
|
+
required_text=\"DEPLOY HOTFIX\"
|
|
297
|
+
fi
|
|
298
|
+
|
|
299
|
+
if [ \"$approval\" != \"$required_text\" ]; then
|
|
300
|
+
echo \"❌ Deployment cancelled\"
|
|
301
|
+
exit 1
|
|
302
|
+
fi
|
|
303
|
+
|
|
304
|
+
echo \"✅ Emergency deployment approved\"
|
|
305
|
+
|
|
306
|
+
# Update incident record
|
|
307
|
+
jq \".status = \\\"approved\\\" | .approved_by = \\\"$(git config user.name)\\\" | .approved_at = \\\"$(date -u +%Y-%m-%dT%H:%M:%SZ)\\\"\" \\
|
|
308
|
+
\".hotfix-$incident_id.json\" > temp.json && mv temp.json \".hotfix-$incident_id.json\"
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
# Request approval
|
|
312
|
+
request_hotfix_approval \"$incident_id\" \"$hotfix_branch\"
|
|
313
|
+
```
|
|
314
|
+
|
|
315
|
+
### 6. Create Hotfix Release
|
|
316
|
+
|
|
317
|
+
```bash
|
|
318
|
+
create_hotfix_release() {
|
|
319
|
+
local incident_id=$1
|
|
320
|
+
local hotfix_branch=$2
|
|
321
|
+
|
|
322
|
+
echo \"📦 Creating hotfix release...\"
|
|
323
|
+
|
|
324
|
+
# Determine current version from production
|
|
325
|
+
if [ -f \"package.json\" ]; then
|
|
326
|
+
current_version=$(jq -r '.version' package.json)
|
|
327
|
+
else
|
|
328
|
+
current_version=$(git describe --tags --abbrev=0 | sed 's/^v//')
|
|
329
|
+
fi
|
|
330
|
+
|
|
331
|
+
# Increment patch version
|
|
332
|
+
IFS='.' read -r major minor patch <<< \"$current_version\"
|
|
333
|
+
patch=$((patch + 1))
|
|
334
|
+
new_version=\"$major.$minor.$patch\"
|
|
335
|
+
|
|
336
|
+
echo \"Current version: $current_version\"
|
|
337
|
+
echo \"New hotfix version: $new_version\"
|
|
338
|
+
|
|
339
|
+
# Update version files
|
|
340
|
+
if [ -f \"package.json\" ]; then
|
|
341
|
+
jq \".version = \\\"$new_version\\\"\" package.json > package.json.tmp
|
|
342
|
+
mv package.json.tmp package.json
|
|
343
|
+
git add package.json
|
|
344
|
+
|
|
345
|
+
if [ -f \"package-lock.json\" ]; then
|
|
346
|
+
jq \".version = \\\"$new_version\\\"\" package-lock.json > package-lock.json.tmp
|
|
347
|
+
mv package-lock.json.tmp package-lock.json
|
|
348
|
+
git add package-lock.json
|
|
349
|
+
fi
|
|
350
|
+
fi
|
|
351
|
+
|
|
352
|
+
# Create release commit
|
|
353
|
+
git commit -m \"chore(hotfix): release v$new_version
|
|
354
|
+
|
|
355
|
+
Incident: $incident_id
|
|
356
|
+
Emergency hotfix deployment
|
|
357
|
+
|
|
358
|
+
🚨 HOTFIX RELEASE\"
|
|
359
|
+
|
|
360
|
+
# Create tag
|
|
361
|
+
git tag -a \"v$new_version\" -m \"Hotfix v$new_version
|
|
362
|
+
|
|
363
|
+
Incident: $incident_id
|
|
364
|
+
Emergency production fix\"
|
|
365
|
+
|
|
366
|
+
echo \"✅ Hotfix release created: v$new_version\"
|
|
367
|
+
|
|
368
|
+
# Update incident record
|
|
369
|
+
jq \".hotfix_version = \\\"$new_version\\\" | .status = \\\"released\\\"\" \\
|
|
370
|
+
\".hotfix-$incident_id.json\" > temp.json && mv temp.json \".hotfix-$incident_id.json\"
|
|
371
|
+
|
|
372
|
+
echo \"$new_version\"
|
|
373
|
+
}
|
|
374
|
+
|
|
375
|
+
# Create release
|
|
376
|
+
hotfix_version=$(create_hotfix_release \"$incident_id\" \"$hotfix_branch\")
|
|
377
|
+
```
|
|
378
|
+
|
|
379
|
+
### 7. Emergency Deployment
|
|
380
|
+
|
|
381
|
+
```bash
|
|
382
|
+
emergency_deploy() {
|
|
383
|
+
local incident_id=$1
|
|
384
|
+
local hotfix_version=$2
|
|
385
|
+
|
|
386
|
+
echo \"🚀 EMERGENCY DEPLOYMENT TO PRODUCTION\"
|
|
387
|
+
echo \"═══════════════════════════════════════\"
|
|
388
|
+
|
|
389
|
+
# Update incident
|
|
390
|
+
jq \".status = \\\"deploying\\\"\" \".hotfix-$incident_id.json\" > temp.json && \\
|
|
391
|
+
mv temp.json \".hotfix-$incident_id.json\"
|
|
392
|
+
|
|
393
|
+
# Send pre-deployment alert
|
|
394
|
+
send_hotfix_alert \"$incident_id\" \"deploying\" \"critical\" \"Emergency deployment in progress\"
|
|
395
|
+
|
|
396
|
+
# Deployment method selection
|
|
397
|
+
if [ -n \"$COOLIFY_URL\" ] && [ -n \"$COOLIFY_PROD_APP_ID\" ]; then
|
|
398
|
+
deploy_via_coolify \"$hotfix_version\"
|
|
399
|
+
elif [ -n \"$DOCKER_REGISTRY\" ]; then
|
|
400
|
+
deploy_via_docker \"$hotfix_version\"
|
|
401
|
+
else
|
|
402
|
+
echo \"❌ No deployment method configured\"
|
|
403
|
+
exit 1
|
|
404
|
+
fi
|
|
405
|
+
|
|
406
|
+
# Update incident
|
|
407
|
+
jq \".status = \\\"deployed\\\" | .deployed_at = \\\"$(date -u +%Y-%m-%dT%H:%M:%SZ)\\\"\" \\
|
|
408
|
+
\".hotfix-$incident_id.json\" > temp.json && mv temp.json \".hotfix-$incident_id.json\"
|
|
409
|
+
}
|
|
410
|
+
|
|
411
|
+
deploy_via_coolify() {
|
|
412
|
+
local version=$1
|
|
413
|
+
|
|
414
|
+
echo \"🚀 Deploying via Coolify...\"
|
|
415
|
+
|
|
416
|
+
# Trigger emergency deployment
|
|
417
|
+
response=$(curl -s -w \"\\n%{http_code}\" -X POST \"$COOLIFY_URL/api/v1/deploy\" \\
|
|
418
|
+
-H \"Authorization: Bearer $COOLIFY_API_TOKEN\" \\
|
|
419
|
+
-H \"Content-Type: application/json\" \\
|
|
420
|
+
-d \"{
|
|
421
|
+
\\\"application_id\\\": \\\"$COOLIFY_PROD_APP_ID\\\",
|
|
422
|
+
\\\"commit\\\": \\\"$(git rev-parse HEAD)\\\",
|
|
423
|
+
\\\"force\\\": true,
|
|
424
|
+
\\\"tag\\\": \\\"v$version\\\"
|
|
425
|
+
}\")
|
|
426
|
+
|
|
427
|
+
http_code=$(echo \"$response\" | tail -1)
|
|
428
|
+
|
|
429
|
+
if [ \"$http_code\" -ne 200 ] && [ \"$http_code\" -ne 201 ]; then
|
|
430
|
+
echo \"❌ Deployment trigger failed\"
|
|
431
|
+
exit 1
|
|
432
|
+
fi
|
|
433
|
+
|
|
434
|
+
echo \"✅ Deployment triggered via Coolify\"
|
|
435
|
+
|
|
436
|
+
# Monitor deployment (quick check)
|
|
437
|
+
echo \"📊 Monitoring deployment...\"
|
|
438
|
+
sleep 30
|
|
439
|
+
|
|
440
|
+
# Quick health check
|
|
441
|
+
if curl -f -s \"$PROD_URL/health\" > /dev/null; then
|
|
442
|
+
echo \"✅ Application responding\"
|
|
443
|
+
else
|
|
444
|
+
echo \"❌ CRITICAL: Application not responding\"
|
|
445
|
+
echo \"🔄 Consider emergency rollback\"
|
|
446
|
+
exit 1
|
|
447
|
+
fi
|
|
448
|
+
}
|
|
449
|
+
|
|
450
|
+
deploy_via_docker() {
|
|
451
|
+
local version=$1
|
|
452
|
+
|
|
453
|
+
echo \"🐳 Deploying via Docker...\"
|
|
454
|
+
|
|
455
|
+
# Build and push
|
|
456
|
+
docker build -t \"$DOCKER_REGISTRY/app:v$version\" .
|
|
457
|
+
docker push \"$DOCKER_REGISTRY/app:v$version\"
|
|
458
|
+
|
|
459
|
+
# Tag as production
|
|
460
|
+
docker tag \"$DOCKER_REGISTRY/app:v$version\" \"$DOCKER_REGISTRY/app:prod\"
|
|
461
|
+
docker push \"$DOCKER_REGISTRY/app:prod\"
|
|
462
|
+
|
|
463
|
+
# Deploy to production
|
|
464
|
+
ssh prod-server << EOF
|
|
465
|
+
docker pull $DOCKER_REGISTRY/app:v$version
|
|
466
|
+
|
|
467
|
+
# Create backup
|
|
468
|
+
docker tag app-prod app-prod-backup
|
|
469
|
+
|
|
470
|
+
# Update production
|
|
471
|
+
docker stop app-prod
|
|
472
|
+
docker rm app-prod
|
|
473
|
+
docker run -d \\
|
|
474
|
+
--name app-prod \\
|
|
475
|
+
--restart unless-stopped \\
|
|
476
|
+
-p 3000:3000 \\
|
|
477
|
+
--env-file /etc/app/prod.env \\
|
|
478
|
+
$DOCKER_REGISTRY/app:v$version
|
|
479
|
+
EOF
|
|
480
|
+
|
|
481
|
+
echo \"✅ Deployed via Docker\"
|
|
482
|
+
|
|
483
|
+
# Quick health check
|
|
484
|
+
sleep 10
|
|
485
|
+
if curl -f -s \"$PROD_URL/health\" > /dev/null; then
|
|
486
|
+
echo \"✅ Application responding\"
|
|
487
|
+
else
|
|
488
|
+
echo \"❌ CRITICAL: Application not responding\"
|
|
489
|
+
exit 1
|
|
490
|
+
fi
|
|
491
|
+
}
|
|
492
|
+
|
|
493
|
+
# Deploy
|
|
494
|
+
emergency_deploy \"$incident_id\" \"$hotfix_version\"
|
|
495
|
+
```
|
|
496
|
+
|
|
497
|
+
### 8. Post-Deployment Verification
|
|
498
|
+
|
|
499
|
+
```bash
|
|
500
|
+
verify_hotfix() {
|
|
501
|
+
local incident_id=$1
|
|
502
|
+
local hotfix_version=$2
|
|
503
|
+
|
|
504
|
+
echo \"🔍 Verifying hotfix deployment...\"
|
|
505
|
+
|
|
506
|
+
# Wait for stabilization
|
|
507
|
+
echo \"⏳ Waiting for deployment to stabilize (30s)...\"
|
|
508
|
+
sleep 30
|
|
509
|
+
|
|
510
|
+
# Health check
|
|
511
|
+
echo \"🏥 Health check...\"
|
|
512
|
+
if ! curl -f -s \"$PROD_URL/health\" > /dev/null; then
|
|
513
|
+
echo \"❌ CRITICAL: Health check failed\"
|
|
514
|
+
initiate_emergency_rollback \"$incident_id\"
|
|
515
|
+
exit 1
|
|
516
|
+
fi
|
|
517
|
+
echo \"✅ Health check passed\"
|
|
518
|
+
|
|
519
|
+
# API endpoints check
|
|
520
|
+
echo \"🔌 API endpoints check...\"
|
|
521
|
+
if ! curl -f -s \"$PROD_URL/api/status\" > /dev/null; then
|
|
522
|
+
echo \"⚠️ API check failed\"
|
|
523
|
+
else
|
|
524
|
+
echo \"✅ API responding\"
|
|
525
|
+
fi
|
|
526
|
+
|
|
527
|
+
# Quick smoke test
|
|
528
|
+
if command -v npm &>/dev/null && grep -q \"\\\"test:smoke:prod\\\"\" package.json 2>/dev/null; then
|
|
529
|
+
echo \"🧪 Running production smoke tests...\"
|
|
530
|
+
npm run test:smoke:prod || {
|
|
531
|
+
echo \"⚠️ Smoke tests failed\"
|
|
532
|
+
read -p \"Continue or rollback? (continue/rollback): \" decision
|
|
533
|
+
if [ \"$decision\" == \"rollback\" ]; then
|
|
534
|
+
initiate_emergency_rollback \"$incident_id\"
|
|
535
|
+
exit 1
|
|
536
|
+
fi
|
|
537
|
+
}
|
|
538
|
+
fi
|
|
539
|
+
|
|
540
|
+
# Monitor error rates
|
|
541
|
+
echo \"📊 Monitoring error rates (2 minutes)...\"
|
|
542
|
+
sleep 120
|
|
543
|
+
|
|
544
|
+
# Check if issue is resolved
|
|
545
|
+
echo \"\"
|
|
546
|
+
read -p \"Is the original issue resolved? (yes/no): \" issue_resolved
|
|
547
|
+
|
|
548
|
+
if [ \"$issue_resolved\" != \"yes\" ]; then
|
|
549
|
+
echo \"⚠️ Issue not resolved\"
|
|
550
|
+
read -p \"Rollback? (yes/no): \" do_rollback
|
|
551
|
+
if [ \"$do_rollback\" == \"yes\" ]; then
|
|
552
|
+
initiate_emergency_rollback \"$incident_id\"
|
|
553
|
+
exit 1
|
|
554
|
+
fi
|
|
555
|
+
fi
|
|
556
|
+
|
|
557
|
+
echo \"✅ Hotfix verification complete\"
|
|
558
|
+
|
|
559
|
+
# Update incident
|
|
560
|
+
jq \".status = \\\"verified\\\" | .issue_resolved = true\" \\
|
|
561
|
+
\".hotfix-$incident_id.json\" > temp.json && mv temp.json \".hotfix-$incident_id.json\"
|
|
562
|
+
}
|
|
563
|
+
|
|
564
|
+
# Verify deployment
|
|
565
|
+
verify_hotfix \"$incident_id\" \"$hotfix_version\"
|
|
566
|
+
```
|
|
567
|
+
|
|
568
|
+
### 9. Emergency Rollback
|
|
569
|
+
|
|
570
|
+
```bash
|
|
571
|
+
initiate_emergency_rollback() {
|
|
572
|
+
local incident_id=$1
|
|
573
|
+
|
|
574
|
+
echo \"🚨 INITIATING EMERGENCY ROLLBACK\"
|
|
575
|
+
echo \"═══════════════════════════════════════\"
|
|
576
|
+
|
|
577
|
+
# Alert team
|
|
578
|
+
send_hotfix_alert \"$incident_id\" \"rolling_back\" \"critical\" \"Emergency rollback in progress\"
|
|
579
|
+
|
|
580
|
+
# Get previous version
|
|
581
|
+
previous_version=$(git tag --sort=-creatordate | grep -E \"^v[0-9]+\\.[0-9]+\\.[0-9]+$\" | sed -n '2p')
|
|
582
|
+
|
|
583
|
+
if [ -z \"$previous_version\" ]; then
|
|
584
|
+
echo \"❌ Cannot determine previous version\"
|
|
585
|
+
exit 1
|
|
586
|
+
fi
|
|
587
|
+
|
|
588
|
+
echo \"Rolling back to: $previous_version\"
|
|
589
|
+
|
|
590
|
+
# Rollback via Coolify
|
|
591
|
+
if [ -n \"$COOLIFY_URL\" ]; then
|
|
592
|
+
curl -X POST \"$COOLIFY_URL/api/v1/deploy\" \\
|
|
593
|
+
-H \"Authorization: Bearer $COOLIFY_API_TOKEN\" \\
|
|
594
|
+
-H \"Content-Type: application/json\" \\
|
|
595
|
+
-d \"{
|
|
596
|
+
\\\"application_id\\\": \\\"$COOLIFY_PROD_APP_ID\\\",
|
|
597
|
+
\\\"tag\\\": \\\"$previous_version\\\",
|
|
598
|
+
\\\"force\\\": true
|
|
599
|
+
}\"
|
|
600
|
+
|
|
601
|
+
sleep 30
|
|
602
|
+
fi
|
|
603
|
+
|
|
604
|
+
# Rollback via Docker
|
|
605
|
+
if [ -n \"$DOCKER_REGISTRY\" ]; then
|
|
606
|
+
ssh prod-server << EOF
|
|
607
|
+
docker stop app-prod
|
|
608
|
+
docker rm app-prod
|
|
609
|
+
docker run -d \\
|
|
610
|
+
--name app-prod \\
|
|
611
|
+
--restart unless-stopped \\
|
|
612
|
+
-p 3000:3000 \\
|
|
613
|
+
--env-file /etc/app/prod.env \\
|
|
614
|
+
app-prod-backup || $DOCKER_REGISTRY/app:$previous_version
|
|
615
|
+
EOF
|
|
616
|
+
|
|
617
|
+
sleep 10
|
|
618
|
+
fi
|
|
619
|
+
|
|
620
|
+
# Verify rollback
|
|
621
|
+
if curl -f -s \"$PROD_URL/health\" > /dev/null; then
|
|
622
|
+
echo \"✅ Rollback successful\"
|
|
623
|
+
send_hotfix_alert \"$incident_id\" \"rolled_back\" \"high\" \"Successfully rolled back to $previous_version\"
|
|
624
|
+
else
|
|
625
|
+
echo \"❌ CRITICAL: Rollback verification failed\"
|
|
626
|
+
echo \"🚨 Manual intervention required immediately\"
|
|
627
|
+
send_hotfix_alert \"$incident_id\" \"rollback_failed\" \"critical\" \"ROLLBACK FAILED - Manual intervention needed\"
|
|
628
|
+
exit 1
|
|
629
|
+
fi
|
|
630
|
+
|
|
631
|
+
# Update incident
|
|
632
|
+
jq \".status = \\\"rolled_back\\\" | .rollback_version = \\\"$previous_version\\\"\" \\
|
|
633
|
+
\".hotfix-$incident_id.json\" > temp.json && mv temp.json \".hotfix-$incident_id.json\"
|
|
634
|
+
}
|
|
635
|
+
```
|
|
636
|
+
|
|
637
|
+
### 10. Merge Hotfix Back
|
|
638
|
+
|
|
639
|
+
```bash
|
|
640
|
+
merge_hotfix_back() {
|
|
641
|
+
local incident_id=$1
|
|
642
|
+
local hotfix_branch=$2
|
|
643
|
+
local hotfix_version=$3
|
|
644
|
+
|
|
645
|
+
echo \"🔀 Merging hotfix back to main branches...\"
|
|
646
|
+
|
|
647
|
+
# Push hotfix branch
|
|
648
|
+
git push origin \"$hotfix_branch\"
|
|
649
|
+
git push origin \"v$hotfix_version\"
|
|
650
|
+
|
|
651
|
+
# Merge to main/master
|
|
652
|
+
main_branch=$(git show-ref --verify --quiet refs/heads/main && echo \"main\" || echo \"master\")
|
|
653
|
+
|
|
654
|
+
echo \"Merging to $main_branch...\"
|
|
655
|
+
git checkout \"$main_branch\"
|
|
656
|
+
git pull origin \"$main_branch\"
|
|
657
|
+
git merge \"$hotfix_branch\" --no-edit
|
|
658
|
+
|
|
659
|
+
# Push main
|
|
660
|
+
git push origin \"$main_branch\"
|
|
661
|
+
|
|
662
|
+
# Merge to develop if exists
|
|
663
|
+
if git show-ref --verify --quiet refs/heads/develop; then
|
|
664
|
+
echo \"Merging to develop...\"
|
|
665
|
+
git checkout develop
|
|
666
|
+
git pull origin develop
|
|
667
|
+
git merge \"$hotfix_branch\" --no-edit
|
|
668
|
+
git push origin develop
|
|
669
|
+
fi
|
|
670
|
+
|
|
671
|
+
# Merge to dev if exists
|
|
672
|
+
if git show-ref --verify --quiet refs/heads/dev; then
|
|
673
|
+
echo \"Merging to dev...\"
|
|
674
|
+
git checkout dev
|
|
675
|
+
git pull origin dev
|
|
676
|
+
git merge \"$hotfix_branch\" --no-edit
|
|
677
|
+
git push origin dev
|
|
678
|
+
fi
|
|
679
|
+
|
|
680
|
+
# Delete hotfix branch
|
|
681
|
+
read -p \"Delete hotfix branch? (yes/no): \" delete_branch
|
|
682
|
+
if [ \"$delete_branch\" == \"yes\" ]; then
|
|
683
|
+
git branch -d \"$hotfix_branch\"
|
|
684
|
+
git push origin --delete \"$hotfix_branch\"
|
|
685
|
+
echo \"✅ Hotfix branch deleted\"
|
|
686
|
+
fi
|
|
687
|
+
|
|
688
|
+
echo \"✅ Hotfix merged back to main branches\"
|
|
689
|
+
}
|
|
690
|
+
|
|
691
|
+
# Merge back
|
|
692
|
+
merge_hotfix_back \"$incident_id\" \"$hotfix_branch\" \"$hotfix_version\"
|
|
693
|
+
```
|
|
694
|
+
|
|
695
|
+
### 11. Post-Mortem Report
|
|
696
|
+
|
|
697
|
+
```bash
|
|
698
|
+
generate_post_mortem() {
|
|
699
|
+
local incident_id=$1
|
|
700
|
+
|
|
701
|
+
echo \"📝 Generating post-mortem report...\"
|
|
702
|
+
|
|
703
|
+
# Load incident data
|
|
704
|
+
if [ ! -f \".hotfix-$incident_id.json\" ]; then
|
|
705
|
+
echo \"❌ Incident record not found\"
|
|
706
|
+
return
|
|
707
|
+
fi
|
|
708
|
+
|
|
709
|
+
incident_data=$(cat \".hotfix-$incident_id.json\")
|
|
710
|
+
|
|
711
|
+
# Create post-mortem
|
|
712
|
+
cat > \"post-mortem-$incident_id.md\" << EOF
|
|
713
|
+
# Post-Mortem: $incident_id
|
|
714
|
+
|
|
715
|
+
**Date:** $(date +%Y-%m-%d)
|
|
716
|
+
**Severity:** $(echo \"$incident_data\" | jq -r '.severity')
|
|
717
|
+
**Status:** $(echo \"$incident_data\" | jq -r '.status')
|
|
718
|
+
|
|
719
|
+
## Incident Summary
|
|
720
|
+
|
|
721
|
+
$(echo \"$incident_data\" | jq -r '.description')
|
|
722
|
+
|
|
723
|
+
## Timeline
|
|
724
|
+
|
|
725
|
+
- **Initiated:** $(echo \"$incident_data\" | jq -r '.timestamp')
|
|
726
|
+
- **Fix Applied:** $(echo \"$incident_data\" | jq -r '.status')
|
|
727
|
+
- **Deployed:** $(echo \"$incident_data\" | jq -r '.deployed_at // \"N/A\"')
|
|
728
|
+
- **Verified:** $(echo \"$incident_data\" | jq -r '.verified_at // \"N/A\"')
|
|
729
|
+
|
|
730
|
+
## Technical Details
|
|
731
|
+
|
|
732
|
+
- **Hotfix Version:** $(echo \"$incident_data\" | jq -r '.hotfix_version')
|
|
733
|
+
- **Base Version:** $(echo \"$incident_data\" | jq -r '.base_ref')
|
|
734
|
+
- **Hotfix Branch:** $(echo \"$incident_data\" | jq -r '.hotfix_branch')
|
|
735
|
+
|
|
736
|
+
## Impact
|
|
737
|
+
|
|
738
|
+
- **Affected Systems:** $(echo \"$incident_data\" | jq -r '.affected_systems')
|
|
739
|
+
- **User Impact:** $(echo \"$incident_data\" | jq -r '.user_impact')
|
|
740
|
+
|
|
741
|
+
## Resolution
|
|
742
|
+
|
|
743
|
+
$(echo \"$incident_data\" | jq -r '.issue_resolved // false' | \\
|
|
744
|
+
sed 's/true/Issue successfully resolved/;s/false/Issue partially resolved/')
|
|
745
|
+
|
|
746
|
+
## Changes Made
|
|
747
|
+
|
|
748
|
+
\\`\\`\\`
|
|
749
|
+
$(git diff \"v$(echo \"$incident_data\" | jq -r '.hotfix_version')^..v$(echo \"$incident_data\" | jq -r '.hotfix_version')\" --stat)
|
|
750
|
+
\\`\\`\\`
|
|
751
|
+
|
|
752
|
+
## Lessons Learned
|
|
753
|
+
|
|
754
|
+
[To be filled by team]
|
|
755
|
+
|
|
756
|
+
## Action Items
|
|
757
|
+
|
|
758
|
+
- [ ] Root cause analysis
|
|
759
|
+
- [ ] Update monitoring/alerts
|
|
760
|
+
- [ ] Add preventive measures
|
|
761
|
+
- [ ] Update documentation
|
|
762
|
+
- [ ] Team debrief
|
|
763
|
+
|
|
764
|
+
## Approval
|
|
765
|
+
|
|
766
|
+
- **Approved By:** $(echo \"$incident_data\" | jq -r '.approved_by // \"N/A\"')
|
|
767
|
+
- **Approved At:** $(echo \"$incident_data\" | jq -r '.approved_at // \"N/A\"')
|
|
768
|
+
|
|
769
|
+
EOF
|
|
770
|
+
|
|
771
|
+
echo \"✅ Post-mortem created: post-mortem-$incident_id.md\"
|
|
772
|
+
|
|
773
|
+
# Clean up incident record
|
|
774
|
+
mv \".hotfix-$incident_id.json\" \"incident-$incident_id.json\"
|
|
775
|
+
}
|
|
776
|
+
|
|
777
|
+
# Generate post-mortem
|
|
778
|
+
generate_post_mortem \"$incident_id\"
|
|
779
|
+
```
|
|
780
|
+
|
|
781
|
+
### 12. Hotfix Notification
|
|
782
|
+
|
|
783
|
+
```bash
|
|
784
|
+
send_hotfix_alert() {
|
|
785
|
+
local incident_id=$1
|
|
786
|
+
local status=$2
|
|
787
|
+
local severity=$3
|
|
788
|
+
local message=$4
|
|
789
|
+
|
|
790
|
+
# Determine color based on severity
|
|
791
|
+
case $severity in
|
|
792
|
+
critical) color=\"16711680\" ;; # Red
|
|
793
|
+
high) color=\"16744192\" ;; # Orange
|
|
794
|
+
medium) color=\"16776960\" ;; # Yellow
|
|
795
|
+
*) color=\"8421504\" ;; # Gray
|
|
796
|
+
esac
|
|
797
|
+
|
|
798
|
+
# Slack notification
|
|
799
|
+
if [ -n \"$SLACK_WEBHOOK_URL\" ]; then
|
|
800
|
+
curl -X POST \"$SLACK_WEBHOOK_URL\" \\
|
|
801
|
+
-H 'Content-Type: application/json' \\
|
|
802
|
+
-d \"{
|
|
803
|
+
\\\"text\\\": \\\"🚨 HOTFIX ALERT\\\",
|
|
804
|
+
\\\"blocks\\\": [
|
|
805
|
+
{
|
|
806
|
+
\\\"type\\\": \\\"header\\\",
|
|
807
|
+
\\\"text\\\": {
|
|
808
|
+
\\\"type\\\": \\\"plain_text\\\",
|
|
809
|
+
\\\"text\\\": \\\"🚨 HOTFIX: $incident_id\\\"
|
|
810
|
+
}
|
|
811
|
+
},
|
|
812
|
+
{
|
|
813
|
+
\\\"type\\\": \\\"section\\\",
|
|
814
|
+
\\\"fields\\\": [
|
|
815
|
+
{\\\"type\\\": \\\"mrkdwn\\\", \\\"text\\\": \\\"*Status:*\\n$status\\\"},
|
|
816
|
+
{\\\"type\\\": \\\"mrkdwn\\\", \\\"text\\\": \\\"*Severity:*\\n$severity\\\"},
|
|
817
|
+
{\\\"type\\\": \\\"mrkdwn\\\", \\\"text\\\": \\\"*Message:*\\n$message\\\"}
|
|
818
|
+
]
|
|
819
|
+
}
|
|
820
|
+
]
|
|
821
|
+
}\"
|
|
822
|
+
fi
|
|
823
|
+
|
|
824
|
+
# Discord notification (with @everyone for critical)
|
|
825
|
+
if [ -n \"$DISCORD_WEBHOOK_URL\" ]; then
|
|
826
|
+
mention=\"\"
|
|
827
|
+
if [ \"$severity\" == \"critical\" ]; then
|
|
828
|
+
mention=\"@everyone \"
|
|
829
|
+
fi
|
|
830
|
+
|
|
831
|
+
curl -X POST \"$DISCORD_WEBHOOK_URL\" \\
|
|
832
|
+
-H 'Content-Type: application/json' \\
|
|
833
|
+
-d \"{
|
|
834
|
+
\\\"content\\\": \\\"${mention}🚨 **HOTFIX ALERT**\\\",
|
|
835
|
+
\\\"embeds\\\": [{
|
|
836
|
+
\\\"title\\\": \\\"Incident: $incident_id\\\",
|
|
837
|
+
\\\"fields\\\": [
|
|
838
|
+
{\\\"name\\\": \\\"Status\\\", \\\"value\\\": \\\"$status\\\", \\\"inline\\\": true},
|
|
839
|
+
{\\\"name\\\": \\\"Severity\\\", \\\"value\\\": \\\"$severity\\\", \\\"inline\\\": true},
|
|
840
|
+
{\\\"name\\\": \\\"Message\\\", \\\"value\\\": \\\"$message\\\"}
|
|
841
|
+
],
|
|
842
|
+
\\\"color\\\": $color,
|
|
843
|
+
\\\"timestamp\\\": \\\"$(date -u +%Y-%m-%dT%H:%M:%SZ)\\\"
|
|
844
|
+
}]
|
|
845
|
+
}\"
|
|
846
|
+
fi
|
|
847
|
+
|
|
848
|
+
# PagerDuty integration (for critical)
|
|
849
|
+
if [ \"$severity\" == \"critical\" ] && [ -n \"$PAGERDUTY_API_KEY\" ]; then
|
|
850
|
+
curl -X POST \"https://api.pagerduty.com/incidents\" \\
|
|
851
|
+
-H \"Authorization: Token token=$PAGERDUTY_API_KEY\" \\
|
|
852
|
+
-H \"Content-Type: application/json\" \\
|
|
853
|
+
-d \"{
|
|
854
|
+
\\\"incident\\\": {
|
|
855
|
+
\\\"type\\\": \\\"incident\\\",
|
|
856
|
+
\\\"title\\\": \\\"HOTFIX: $incident_id\\\",
|
|
857
|
+
\\\"service\\\": {\\\"id\\\": \\\"$PAGERDUTY_SERVICE_ID\\\", \\\"type\\\": \\\"service_reference\\\"},
|
|
858
|
+
\\\"urgency\\\": \\\"high\\\",
|
|
859
|
+
\\\"body\\\": {\\\"type\\\": \\\"incident_body\\\", \\\"details\\\": \\\"$message\\\"}
|
|
860
|
+
}
|
|
861
|
+
}\"
|
|
862
|
+
fi
|
|
863
|
+
}
|
|
864
|
+
```
|
|
865
|
+
|
|
866
|
+
## Complete Hotfix Script
|
|
867
|
+
|
|
868
|
+
```bash
|
|
869
|
+
#!/bin/bash
|
|
870
|
+
set -e
|
|
871
|
+
|
|
872
|
+
echo \"🚨 EMERGENCY HOTFIX PROCEDURE\"
|
|
873
|
+
echo \"═══════════════════════════════════════\"
|
|
874
|
+
|
|
875
|
+
# 1. Assess emergency
|
|
876
|
+
incident_id=$(assess_hotfix_urgency)
|
|
877
|
+
|
|
878
|
+
# 2. Create hotfix branch from production
|
|
879
|
+
hotfix_branch=$(create_hotfix_branch \"$incident_id\")
|
|
880
|
+
|
|
881
|
+
# 3. Apply fix
|
|
882
|
+
apply_hotfix \"$incident_id\" \"$hotfix_branch\"
|
|
883
|
+
|
|
884
|
+
# 4. Fast-track testing
|
|
885
|
+
fast_track_testing \"$incident_id\"
|
|
886
|
+
|
|
887
|
+
# 5. Request approval
|
|
888
|
+
request_hotfix_approval \"$incident_id\" \"$hotfix_branch\"
|
|
889
|
+
|
|
890
|
+
# 6. Create release
|
|
891
|
+
hotfix_version=$(create_hotfix_release \"$incident_id\" \"$hotfix_branch\")
|
|
892
|
+
|
|
893
|
+
# 7. Emergency deploy
|
|
894
|
+
emergency_deploy \"$incident_id\" \"$hotfix_version\"
|
|
895
|
+
|
|
896
|
+
# 8. Verify deployment
|
|
897
|
+
verify_hotfix \"$incident_id\" \"$hotfix_version\"
|
|
898
|
+
|
|
899
|
+
# 9. Merge back
|
|
900
|
+
merge_hotfix_back \"$incident_id\" \"$hotfix_branch\" \"$hotfix_version\"
|
|
901
|
+
|
|
902
|
+
# 10. Generate post-mortem
|
|
903
|
+
generate_post_mortem \"$incident_id\"
|
|
904
|
+
|
|
905
|
+
# 11. Final notification
|
|
906
|
+
send_hotfix_alert \"$incident_id\" \"completed\" \"high\" \"Hotfix v$hotfix_version deployed and verified\"
|
|
907
|
+
|
|
908
|
+
echo \"✅ HOTFIX COMPLETE\"
|
|
909
|
+
echo \"Incident ID: $incident_id\"
|
|
910
|
+
echo \"Version: v$hotfix_version\"
|
|
911
|
+
```
|
|
912
|
+
|
|
913
|
+
## Quick Hotfix Commands
|
|
914
|
+
|
|
915
|
+
```bash
|
|
916
|
+
# Start hotfix procedure
|
|
917
|
+
/myai-git-hotfix
|
|
918
|
+
|
|
919
|
+
# Emergency rollback
|
|
920
|
+
/myai-git-hotfix --rollback
|
|
921
|
+
|
|
922
|
+
# Generate post-mortem only
|
|
923
|
+
/myai-git-hotfix --post-mortem <incident-id>
|
|
924
|
+
```
|
|
925
|
+
|
|
926
|
+
## Environment Configuration
|
|
927
|
+
|
|
928
|
+
```bash
|
|
929
|
+
# Production
|
|
930
|
+
PROD_URL=https://your-app.com
|
|
931
|
+
|
|
932
|
+
# Coolify
|
|
933
|
+
COOLIFY_URL=https://coolify.your-server.com
|
|
934
|
+
COOLIFY_API_TOKEN=your_token
|
|
935
|
+
COOLIFY_PROD_APP_ID=your_app_id
|
|
936
|
+
|
|
937
|
+
# Docker
|
|
938
|
+
DOCKER_REGISTRY=registry.your-domain.com
|
|
939
|
+
|
|
940
|
+
# Notifications (CRITICAL)
|
|
941
|
+
SLACK_WEBHOOK_URL=https://hooks.slack.com/services/YOUR/WEBHOOK
|
|
942
|
+
DISCORD_WEBHOOK_URL=https://discord.com/api/webhooks/YOUR/WEBHOOK
|
|
943
|
+
PAGERDUTY_API_KEY=your_pagerduty_key
|
|
944
|
+
PAGERDUTY_SERVICE_ID=your_service_id
|
|
945
|
+
|
|
946
|
+
# Team
|
|
947
|
+
ONCALL_EMAIL=oncall@yourcompany.com
|
|
948
|
+
TEAM_CHANNEL=#incidents
|
|
949
|
+
```
|
|
950
|
+
|
|
951
|
+
Execute emergency hotfix procedure with fast-track deployment and rollback safeguards.
|
|
952
|
+
|
|
953
|
+
"""
|