myaidev-method 0.2.5 → 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 +161 -70
- 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,512 @@
|
|
|
1
|
+
# Create and deploy emergency hotfixes with fast-track procedures
|
|
2
|
+
|
|
3
|
+
You are a hotfix automation assistant specializing in emergency production fixes with rapid deployment.
|
|
4
|
+
|
|
5
|
+
Task: Create and deploy hotfix - $ARGUMENTS
|
|
6
|
+
|
|
7
|
+
## Hotfix Workflow
|
|
8
|
+
|
|
9
|
+
### 1. Emergency Assessment
|
|
10
|
+
|
|
11
|
+
```bash
|
|
12
|
+
assess_hotfix_urgency() {
|
|
13
|
+
echo "🚨 HOTFIX EMERGENCY ASSESSMENT"
|
|
14
|
+
echo "═══════════════════════════════════════"
|
|
15
|
+
|
|
16
|
+
# Gather incident information
|
|
17
|
+
read -p "Issue description: " issue_desc
|
|
18
|
+
read -p "Severity (critical/high/medium): " severity
|
|
19
|
+
read -p "Affected systems: " affected_systems
|
|
20
|
+
read -p "User impact: " user_impact
|
|
21
|
+
|
|
22
|
+
# Create incident record
|
|
23
|
+
incident_id="HOTFIX-$(date +%Y%m%d-%H%M%S)"
|
|
24
|
+
|
|
25
|
+
cat > ".hotfix-$incident_id.json" << EOF
|
|
26
|
+
{
|
|
27
|
+
"incident_id": "$incident_id",
|
|
28
|
+
"timestamp": "$(date -u +%Y-%m-%dT%H:%M:%SZ)",
|
|
29
|
+
"severity": "$severity",
|
|
30
|
+
"description": "$issue_desc",
|
|
31
|
+
"affected_systems": "$affected_systems",
|
|
32
|
+
"user_impact": "$user_impact",
|
|
33
|
+
"status": "initiated"
|
|
34
|
+
}
|
|
35
|
+
EOF
|
|
36
|
+
|
|
37
|
+
echo ""
|
|
38
|
+
echo "╔══════════════════════════════════════════════════════════╗"
|
|
39
|
+
echo "║ HOTFIX INCIDENT CREATED ║"
|
|
40
|
+
echo "╚══════════════════════════════════════════════════════════╝"
|
|
41
|
+
echo "Incident ID: $incident_id"
|
|
42
|
+
echo "Severity: $severity"
|
|
43
|
+
echo "Description: $issue_desc"
|
|
44
|
+
echo ""
|
|
45
|
+
|
|
46
|
+
echo "$incident_id"
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
# Create incident
|
|
50
|
+
incident_id=$(assess_hotfix_urgency)
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
### 2. Create Hotfix Branch from Production
|
|
54
|
+
|
|
55
|
+
```bash
|
|
56
|
+
create_hotfix_branch() {
|
|
57
|
+
local incident_id=$1
|
|
58
|
+
local hotfix_branch="hotfix/$incident_id"
|
|
59
|
+
|
|
60
|
+
echo "🔧 Creating hotfix branch from production..."
|
|
61
|
+
|
|
62
|
+
# Fetch latest
|
|
63
|
+
git fetch --all
|
|
64
|
+
|
|
65
|
+
# Determine production branch/tag
|
|
66
|
+
if git show-ref --verify --quiet refs/heads/production; then
|
|
67
|
+
base_branch="production"
|
|
68
|
+
elif git show-ref --verify --quiet refs/heads/main; then
|
|
69
|
+
base_branch="main"
|
|
70
|
+
else
|
|
71
|
+
base_branch="master"
|
|
72
|
+
fi
|
|
73
|
+
|
|
74
|
+
# Get production tag (most recent release)
|
|
75
|
+
latest_prod_tag=$(git tag --sort=-creatordate | grep -E "^v[0-9]+\.[0-9]+\.[0-9]+$" | head -1)
|
|
76
|
+
|
|
77
|
+
if [ -n "$latest_prod_tag" ]; then
|
|
78
|
+
echo "🏷️ Creating hotfix from production tag: $latest_prod_tag"
|
|
79
|
+
base_ref="$latest_prod_tag"
|
|
80
|
+
else
|
|
81
|
+
echo "📍 Creating hotfix from $base_branch branch"
|
|
82
|
+
base_ref="origin/$base_branch"
|
|
83
|
+
fi
|
|
84
|
+
|
|
85
|
+
# Create hotfix branch
|
|
86
|
+
git checkout -b "$hotfix_branch" "$base_ref" || {
|
|
87
|
+
echo "❌ Failed to create hotfix branch"
|
|
88
|
+
exit 1
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
echo "✅ Hotfix branch created: $hotfix_branch"
|
|
92
|
+
echo "📍 Base: $base_ref"
|
|
93
|
+
|
|
94
|
+
echo "$hotfix_branch"
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
# Create hotfix branch
|
|
98
|
+
hotfix_branch=$(create_hotfix_branch "$incident_id")
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
### 3. Apply Hotfix (Guided)
|
|
102
|
+
|
|
103
|
+
```bash
|
|
104
|
+
apply_hotfix() {
|
|
105
|
+
local incident_id=$1
|
|
106
|
+
local hotfix_branch=$2
|
|
107
|
+
|
|
108
|
+
echo "🔧 Applying hotfix..."
|
|
109
|
+
echo ""
|
|
110
|
+
echo "Options:"
|
|
111
|
+
echo " 1. Apply existing patch file"
|
|
112
|
+
echo " 2. Make manual code changes"
|
|
113
|
+
echo " 3. Cherry-pick from another branch"
|
|
114
|
+
echo " 4. Revert specific commit"
|
|
115
|
+
echo ""
|
|
116
|
+
|
|
117
|
+
read -p "Choose option (1-4): " fix_option
|
|
118
|
+
|
|
119
|
+
case $fix_option in
|
|
120
|
+
1)
|
|
121
|
+
# Apply patch file
|
|
122
|
+
read -p "Enter patch file path: " patch_file
|
|
123
|
+
if [ -f "$patch_file" ]; then
|
|
124
|
+
git apply "$patch_file" || {
|
|
125
|
+
echo "❌ Failed to apply patch"
|
|
126
|
+
exit 1
|
|
127
|
+
}
|
|
128
|
+
git add -A
|
|
129
|
+
git commit -m "hotfix: apply patch from $patch_file"
|
|
130
|
+
else
|
|
131
|
+
echo "❌ Patch file not found"
|
|
132
|
+
exit 1
|
|
133
|
+
fi
|
|
134
|
+
;;
|
|
135
|
+
|
|
136
|
+
2)
|
|
137
|
+
# Manual changes
|
|
138
|
+
echo "📝 Make your code changes now"
|
|
139
|
+
echo "Press Enter when ready to continue..."
|
|
140
|
+
read
|
|
141
|
+
|
|
142
|
+
if git diff-index --quiet HEAD --; then
|
|
143
|
+
echo "⚠️ No changes detected"
|
|
144
|
+
exit 1
|
|
145
|
+
fi
|
|
146
|
+
|
|
147
|
+
git add -A
|
|
148
|
+
|
|
149
|
+
read -p "Commit message: " commit_msg
|
|
150
|
+
git commit -m "hotfix: $commit_msg"
|
|
151
|
+
;;
|
|
152
|
+
|
|
153
|
+
3)
|
|
154
|
+
# Cherry-pick
|
|
155
|
+
read -p "Enter commit hash to cherry-pick: " commit_hash
|
|
156
|
+
git cherry-pick "$commit_hash" || {
|
|
157
|
+
echo "❌ Cherry-pick failed"
|
|
158
|
+
echo "Resolve conflicts and run: git cherry-pick --continue"
|
|
159
|
+
exit 1
|
|
160
|
+
}
|
|
161
|
+
;;
|
|
162
|
+
|
|
163
|
+
4)
|
|
164
|
+
# Revert commit
|
|
165
|
+
read -p "Enter commit hash to revert: " commit_hash
|
|
166
|
+
git revert "$commit_hash" --no-edit || {
|
|
167
|
+
echo "❌ Revert failed"
|
|
168
|
+
exit 1
|
|
169
|
+
}
|
|
170
|
+
;;
|
|
171
|
+
|
|
172
|
+
*)
|
|
173
|
+
echo "Invalid option"
|
|
174
|
+
exit 1
|
|
175
|
+
;;
|
|
176
|
+
esac
|
|
177
|
+
|
|
178
|
+
echo "✅ Hotfix applied"
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
# Apply fix
|
|
182
|
+
apply_hotfix "$incident_id" "$hotfix_branch"
|
|
183
|
+
```
|
|
184
|
+
|
|
185
|
+
### 4. Fast-Track Testing
|
|
186
|
+
|
|
187
|
+
```bash
|
|
188
|
+
fast_track_testing() {
|
|
189
|
+
local incident_id=$1
|
|
190
|
+
|
|
191
|
+
echo "🧪 Running fast-track tests..."
|
|
192
|
+
|
|
193
|
+
# Critical tests only
|
|
194
|
+
echo "Running critical test suite..."
|
|
195
|
+
|
|
196
|
+
# Unit tests
|
|
197
|
+
if command -v npm &>/dev/null && grep -q "\"test:critical\"" package.json 2>/dev/null; then
|
|
198
|
+
npm run test:critical || {
|
|
199
|
+
echo "❌ CRITICAL: Tests failed"
|
|
200
|
+
exit 1
|
|
201
|
+
}
|
|
202
|
+
elif command -v npm &>/dev/null; then
|
|
203
|
+
npm test || {
|
|
204
|
+
echo "❌ CRITICAL: Tests failed"
|
|
205
|
+
exit 1
|
|
206
|
+
}
|
|
207
|
+
fi
|
|
208
|
+
|
|
209
|
+
# Build test
|
|
210
|
+
echo "Testing build..."
|
|
211
|
+
if command -v npm &>/dev/null && grep -q "\"build\"" package.json 2>/dev/null; then
|
|
212
|
+
npm run build || {
|
|
213
|
+
echo "❌ CRITICAL: Build failed"
|
|
214
|
+
exit 1
|
|
215
|
+
}
|
|
216
|
+
fi
|
|
217
|
+
|
|
218
|
+
echo "✅ Fast-track tests passed"
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
# Run tests
|
|
222
|
+
fast_track_testing "$incident_id"
|
|
223
|
+
```
|
|
224
|
+
|
|
225
|
+
### 5. Emergency Approval
|
|
226
|
+
|
|
227
|
+
```bash
|
|
228
|
+
request_hotfix_approval() {
|
|
229
|
+
local incident_id=$1
|
|
230
|
+
local hotfix_branch=$2
|
|
231
|
+
|
|
232
|
+
echo ""
|
|
233
|
+
echo "╔══════════════════════════════════════════════════════════╗"
|
|
234
|
+
echo "║ 🚨 EMERGENCY HOTFIX APPROVAL 🚨 ║"
|
|
235
|
+
echo "╚══════════════════════════════════════════════════════════╝"
|
|
236
|
+
echo ""
|
|
237
|
+
echo "Incident ID: $incident_id"
|
|
238
|
+
echo "Hotfix Branch: $hotfix_branch"
|
|
239
|
+
echo ""
|
|
240
|
+
|
|
241
|
+
# Show changes
|
|
242
|
+
echo "Changes:"
|
|
243
|
+
git diff HEAD~1 --stat
|
|
244
|
+
echo ""
|
|
245
|
+
|
|
246
|
+
# Require explicit approval
|
|
247
|
+
if [ -f ".hotfix-$incident_id.json" ]; then
|
|
248
|
+
severity=$(jq -r '.severity' ".hotfix-$incident_id.json")
|
|
249
|
+
|
|
250
|
+
if [ "$severity" == "critical" ]; then
|
|
251
|
+
read -p "Type 'EMERGENCY DEPLOY' to approve: " approval
|
|
252
|
+
required_text="EMERGENCY DEPLOY"
|
|
253
|
+
else
|
|
254
|
+
read -p "Type 'DEPLOY HOTFIX' to approve: " approval
|
|
255
|
+
required_text="DEPLOY HOTFIX"
|
|
256
|
+
fi
|
|
257
|
+
else
|
|
258
|
+
read -p "Type 'DEPLOY HOTFIX' to approve: " approval
|
|
259
|
+
required_text="DEPLOY HOTFIX"
|
|
260
|
+
fi
|
|
261
|
+
|
|
262
|
+
if [ "$approval" != "$required_text" ]; then
|
|
263
|
+
echo "❌ Deployment cancelled"
|
|
264
|
+
exit 1
|
|
265
|
+
fi
|
|
266
|
+
|
|
267
|
+
echo "✅ Emergency deployment approved"
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
# Request approval
|
|
271
|
+
request_hotfix_approval "$incident_id" "$hotfix_branch"
|
|
272
|
+
```
|
|
273
|
+
|
|
274
|
+
### 6. Create Hotfix Release
|
|
275
|
+
|
|
276
|
+
```bash
|
|
277
|
+
create_hotfix_release() {
|
|
278
|
+
local incident_id=$1
|
|
279
|
+
local hotfix_branch=$2
|
|
280
|
+
|
|
281
|
+
echo "📦 Creating hotfix release..."
|
|
282
|
+
|
|
283
|
+
# Determine current version from production
|
|
284
|
+
if [ -f "package.json" ]; then
|
|
285
|
+
current_version=$(jq -r '.version' package.json)
|
|
286
|
+
else
|
|
287
|
+
current_version=$(git describe --tags --abbrev=0 | sed 's/^v//')
|
|
288
|
+
fi
|
|
289
|
+
|
|
290
|
+
# Increment patch version
|
|
291
|
+
IFS='.' read -r major minor patch <<< "$current_version"
|
|
292
|
+
patch=$((patch + 1))
|
|
293
|
+
new_version="$major.$minor.$patch"
|
|
294
|
+
|
|
295
|
+
echo "Current version: $current_version"
|
|
296
|
+
echo "New hotfix version: $new_version"
|
|
297
|
+
|
|
298
|
+
# Update version files
|
|
299
|
+
if [ -f "package.json" ]; then
|
|
300
|
+
jq ".version = \"$new_version\"" package.json > package.json.tmp
|
|
301
|
+
mv package.json.tmp package.json
|
|
302
|
+
git add package.json
|
|
303
|
+
|
|
304
|
+
if [ -f "package-lock.json" ]; then
|
|
305
|
+
jq ".version = \"$new_version\"" package-lock.json > package-lock.json.tmp
|
|
306
|
+
mv package-lock.json.tmp package-lock.json
|
|
307
|
+
git add package-lock.json
|
|
308
|
+
fi
|
|
309
|
+
fi
|
|
310
|
+
|
|
311
|
+
# Create release commit
|
|
312
|
+
git commit -m "chore(hotfix): release v$new_version
|
|
313
|
+
|
|
314
|
+
Incident: $incident_id
|
|
315
|
+
Emergency hotfix deployment
|
|
316
|
+
|
|
317
|
+
🚨 HOTFIX RELEASE"
|
|
318
|
+
|
|
319
|
+
# Create tag
|
|
320
|
+
git tag -a "v$new_version" -m "Hotfix v$new_version
|
|
321
|
+
|
|
322
|
+
Incident: $incident_id
|
|
323
|
+
Emergency production fix"
|
|
324
|
+
|
|
325
|
+
echo "✅ Hotfix release created: v$new_version"
|
|
326
|
+
echo "$new_version"
|
|
327
|
+
}
|
|
328
|
+
|
|
329
|
+
# Create release
|
|
330
|
+
hotfix_version=$(create_hotfix_release "$incident_id" "$hotfix_branch")
|
|
331
|
+
```
|
|
332
|
+
|
|
333
|
+
### 7. Emergency Deployment
|
|
334
|
+
|
|
335
|
+
```bash
|
|
336
|
+
emergency_deploy() {
|
|
337
|
+
local incident_id=$1
|
|
338
|
+
local hotfix_version=$2
|
|
339
|
+
|
|
340
|
+
echo "🚀 EMERGENCY DEPLOYMENT TO PRODUCTION"
|
|
341
|
+
echo "═══════════════════════════════════════"
|
|
342
|
+
|
|
343
|
+
# Deployment method selection
|
|
344
|
+
if [ -n "$COOLIFY_URL" ] && [ -n "$COOLIFY_PROD_APP_ID" ]; then
|
|
345
|
+
# Coolify method
|
|
346
|
+
echo "🚀 Deploying via Coolify..."
|
|
347
|
+
|
|
348
|
+
response=$(curl -s -w "\n%{http_code}" -X POST "$COOLIFY_URL/api/v1/deploy" \
|
|
349
|
+
-H "Authorization: Bearer $COOLIFY_API_TOKEN" \
|
|
350
|
+
-H "Content-Type: application/json" \
|
|
351
|
+
-d "{
|
|
352
|
+
\"application_id\": \"$COOLIFY_PROD_APP_ID\",
|
|
353
|
+
\"commit\": \"$(git rev-parse HEAD)\",
|
|
354
|
+
\"force\": true,
|
|
355
|
+
\"tag\": \"v$hotfix_version\"
|
|
356
|
+
}")
|
|
357
|
+
|
|
358
|
+
http_code=$(echo "$response" | tail -1)
|
|
359
|
+
|
|
360
|
+
if [ "$http_code" -ne 200 ] && [ "$http_code" -ne 201 ]; then
|
|
361
|
+
echo "❌ Deployment trigger failed"
|
|
362
|
+
exit 1
|
|
363
|
+
fi
|
|
364
|
+
|
|
365
|
+
echo "✅ Deployment triggered via Coolify"
|
|
366
|
+
|
|
367
|
+
elif [ -n "$DOCKER_REGISTRY" ]; then
|
|
368
|
+
# Docker method
|
|
369
|
+
echo "🐳 Deploying via Docker..."
|
|
370
|
+
|
|
371
|
+
docker build -t "$DOCKER_REGISTRY/app:v$hotfix_version" .
|
|
372
|
+
docker push "$DOCKER_REGISTRY/app:v$hotfix_version"
|
|
373
|
+
|
|
374
|
+
ssh prod-server << EOF
|
|
375
|
+
docker pull $DOCKER_REGISTRY/app:v$hotfix_version
|
|
376
|
+
docker stop app-prod
|
|
377
|
+
docker rm app-prod
|
|
378
|
+
docker run -d \
|
|
379
|
+
--name app-prod \
|
|
380
|
+
--restart unless-stopped \
|
|
381
|
+
-p 3000:3000 \
|
|
382
|
+
--env-file /etc/app/prod.env \
|
|
383
|
+
$DOCKER_REGISTRY/app:v$hotfix_version
|
|
384
|
+
EOF
|
|
385
|
+
|
|
386
|
+
echo "✅ Deployed via Docker"
|
|
387
|
+
else
|
|
388
|
+
echo "❌ No deployment method configured"
|
|
389
|
+
exit 1
|
|
390
|
+
fi
|
|
391
|
+
|
|
392
|
+
# Quick health check
|
|
393
|
+
sleep 10
|
|
394
|
+
if curl -f -s "$PROD_URL/health" > /dev/null; then
|
|
395
|
+
echo "✅ Application responding"
|
|
396
|
+
else
|
|
397
|
+
echo "❌ CRITICAL: Application not responding"
|
|
398
|
+
exit 1
|
|
399
|
+
fi
|
|
400
|
+
}
|
|
401
|
+
|
|
402
|
+
# Deploy
|
|
403
|
+
emergency_deploy "$incident_id" "$hotfix_version"
|
|
404
|
+
```
|
|
405
|
+
|
|
406
|
+
### 8. Merge Hotfix Back
|
|
407
|
+
|
|
408
|
+
```bash
|
|
409
|
+
merge_hotfix_back() {
|
|
410
|
+
local incident_id=$1
|
|
411
|
+
local hotfix_branch=$2
|
|
412
|
+
local hotfix_version=$3
|
|
413
|
+
|
|
414
|
+
echo "🔀 Merging hotfix back to main branches..."
|
|
415
|
+
|
|
416
|
+
# Push hotfix branch
|
|
417
|
+
git push origin "$hotfix_branch"
|
|
418
|
+
git push origin "v$hotfix_version"
|
|
419
|
+
|
|
420
|
+
# Merge to main/master
|
|
421
|
+
main_branch=$(git show-ref --verify --quiet refs/heads/main && echo "main" || echo "master")
|
|
422
|
+
|
|
423
|
+
echo "Merging to $main_branch..."
|
|
424
|
+
git checkout "$main_branch"
|
|
425
|
+
git pull origin "$main_branch"
|
|
426
|
+
git merge "$hotfix_branch" --no-edit
|
|
427
|
+
|
|
428
|
+
# Push main
|
|
429
|
+
git push origin "$main_branch"
|
|
430
|
+
|
|
431
|
+
# Merge to develop if exists
|
|
432
|
+
if git show-ref --verify --quiet refs/heads/develop; then
|
|
433
|
+
echo "Merging to develop..."
|
|
434
|
+
git checkout develop
|
|
435
|
+
git pull origin develop
|
|
436
|
+
git merge "$hotfix_branch" --no-edit
|
|
437
|
+
git push origin develop
|
|
438
|
+
fi
|
|
439
|
+
|
|
440
|
+
# Delete hotfix branch
|
|
441
|
+
read -p "Delete hotfix branch? (yes/no): " delete_branch
|
|
442
|
+
if [ "$delete_branch" == "yes" ]; then
|
|
443
|
+
git branch -d "$hotfix_branch"
|
|
444
|
+
git push origin --delete "$hotfix_branch"
|
|
445
|
+
echo "✅ Hotfix branch deleted"
|
|
446
|
+
fi
|
|
447
|
+
|
|
448
|
+
echo "✅ Hotfix merged back to main branches"
|
|
449
|
+
}
|
|
450
|
+
|
|
451
|
+
# Merge back
|
|
452
|
+
merge_hotfix_back "$incident_id" "$hotfix_branch" "$hotfix_version"
|
|
453
|
+
```
|
|
454
|
+
|
|
455
|
+
## Complete Hotfix Script
|
|
456
|
+
|
|
457
|
+
```bash
|
|
458
|
+
#!/bin/bash
|
|
459
|
+
set -e
|
|
460
|
+
|
|
461
|
+
echo "🚨 EMERGENCY HOTFIX PROCEDURE"
|
|
462
|
+
echo "═══════════════════════════════════════"
|
|
463
|
+
|
|
464
|
+
# 1. Assess emergency
|
|
465
|
+
incident_id=$(assess_hotfix_urgency)
|
|
466
|
+
|
|
467
|
+
# 2. Create hotfix branch from production
|
|
468
|
+
hotfix_branch=$(create_hotfix_branch "$incident_id")
|
|
469
|
+
|
|
470
|
+
# 3. Apply fix
|
|
471
|
+
apply_hotfix "$incident_id" "$hotfix_branch"
|
|
472
|
+
|
|
473
|
+
# 4. Fast-track testing
|
|
474
|
+
fast_track_testing "$incident_id"
|
|
475
|
+
|
|
476
|
+
# 5. Request approval
|
|
477
|
+
request_hotfix_approval "$incident_id" "$hotfix_branch"
|
|
478
|
+
|
|
479
|
+
# 6. Create release
|
|
480
|
+
hotfix_version=$(create_hotfix_release "$incident_id" "$hotfix_branch")
|
|
481
|
+
|
|
482
|
+
# 7. Emergency deploy
|
|
483
|
+
emergency_deploy "$incident_id" "$hotfix_version"
|
|
484
|
+
|
|
485
|
+
# 8. Merge back
|
|
486
|
+
merge_hotfix_back "$incident_id" "$hotfix_branch" "$hotfix_version"
|
|
487
|
+
|
|
488
|
+
echo "✅ HOTFIX COMPLETE"
|
|
489
|
+
echo "Incident ID: $incident_id"
|
|
490
|
+
echo "Version: v$hotfix_version"
|
|
491
|
+
```
|
|
492
|
+
|
|
493
|
+
## Environment Configuration
|
|
494
|
+
|
|
495
|
+
```bash
|
|
496
|
+
# Production
|
|
497
|
+
PROD_URL=https://your-app.com
|
|
498
|
+
|
|
499
|
+
# Coolify
|
|
500
|
+
COOLIFY_URL=https://coolify.your-server.com
|
|
501
|
+
COOLIFY_API_TOKEN=your_token
|
|
502
|
+
COOLIFY_PROD_APP_ID=your_app_id
|
|
503
|
+
|
|
504
|
+
# Docker
|
|
505
|
+
DOCKER_REGISTRY=registry.your-domain.com
|
|
506
|
+
|
|
507
|
+
# Notifications (CRITICAL)
|
|
508
|
+
SLACK_WEBHOOK_URL=https://hooks.slack.com/services/YOUR/WEBHOOK
|
|
509
|
+
DISCORD_WEBHOOK_URL=https://discord.com/api/webhooks/YOUR/WEBHOOK
|
|
510
|
+
```
|
|
511
|
+
|
|
512
|
+
Execute emergency hotfix procedure with fast-track deployment and rollback safeguards.
|
|
@@ -0,0 +1,196 @@
|
|
|
1
|
+
# Create and manage GitHub Pull Requests with AI assistance
|
|
2
|
+
|
|
3
|
+
You are a Git and GitHub workflow assistant specializing in creating professional pull requests.
|
|
4
|
+
|
|
5
|
+
Task: $ARGUMENTS
|
|
6
|
+
|
|
7
|
+
## Pull Request Workflow
|
|
8
|
+
|
|
9
|
+
### 1. Analyze Current State
|
|
10
|
+
```bash
|
|
11
|
+
git status
|
|
12
|
+
git branch
|
|
13
|
+
git diff main...HEAD
|
|
14
|
+
git log --oneline -10
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
### 2. Create Pull Request
|
|
18
|
+
|
|
19
|
+
**Analyze Changes:**
|
|
20
|
+
- Review all commits since branch diverged from main
|
|
21
|
+
- Identify the core feature/fix being implemented
|
|
22
|
+
- Note any breaking changes or migrations
|
|
23
|
+
- Check for related issues or tickets
|
|
24
|
+
|
|
25
|
+
**PR Title Format:**
|
|
26
|
+
- Feature: `feat: Add user authentication with JWT`
|
|
27
|
+
- Fix: `fix: Resolve memory leak in WebSocket connection`
|
|
28
|
+
- Docs: `docs: Update API documentation for v2.0`
|
|
29
|
+
- Refactor: `refactor: Optimize database query performance`
|
|
30
|
+
- Chore: `chore: Update dependencies to latest versions`
|
|
31
|
+
|
|
32
|
+
**PR Description Template:**
|
|
33
|
+
```markdown
|
|
34
|
+
## Summary
|
|
35
|
+
[2-3 sentence overview of what this PR does]
|
|
36
|
+
|
|
37
|
+
## Changes
|
|
38
|
+
- **Feature/Component 1**: [What changed and why]
|
|
39
|
+
- **Feature/Component 2**: [What changed and why]
|
|
40
|
+
- **Tests**: [Testing added/updated]
|
|
41
|
+
|
|
42
|
+
## Type of Change
|
|
43
|
+
- [ ] Bug fix (non-breaking change fixing an issue)
|
|
44
|
+
- [ ] New feature (non-breaking change adding functionality)
|
|
45
|
+
- [ ] Breaking change (fix or feature causing existing functionality to break)
|
|
46
|
+
- [ ] Documentation update
|
|
47
|
+
|
|
48
|
+
## Testing
|
|
49
|
+
- [ ] Unit tests pass locally
|
|
50
|
+
- [ ] Integration tests pass locally
|
|
51
|
+
- [ ] Manual testing completed
|
|
52
|
+
- [ ] No console errors or warnings
|
|
53
|
+
|
|
54
|
+
## Checklist
|
|
55
|
+
- [ ] Code follows project style guidelines
|
|
56
|
+
- [ ] Self-review completed
|
|
57
|
+
- [ ] Comments added for complex logic
|
|
58
|
+
- [ ] Documentation updated
|
|
59
|
+
- [ ] No new warnings generated
|
|
60
|
+
- [ ] Tests added/updated for changes
|
|
61
|
+
- [ ] All tests passing
|
|
62
|
+
|
|
63
|
+
## Related Issues
|
|
64
|
+
Closes #[issue number]
|
|
65
|
+
Fixes #[issue number]
|
|
66
|
+
Relates to #[issue number]
|
|
67
|
+
|
|
68
|
+
## Screenshots (if applicable)
|
|
69
|
+
[Add screenshots or GIFs demonstrating the changes]
|
|
70
|
+
|
|
71
|
+
## Deployment Notes
|
|
72
|
+
[Any special deployment considerations]
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
### 3. Create PR Using GitHub CLI
|
|
76
|
+
|
|
77
|
+
```bash
|
|
78
|
+
# Ensure branch is pushed
|
|
79
|
+
git push -u origin $(git branch --show-current)
|
|
80
|
+
|
|
81
|
+
# Create PR with gh CLI
|
|
82
|
+
gh pr create \
|
|
83
|
+
--title "Your PR Title" \
|
|
84
|
+
--body "$(cat <<'EOF'
|
|
85
|
+
[Your PR description from template above]
|
|
86
|
+
EOF
|
|
87
|
+
)" \
|
|
88
|
+
--base main \
|
|
89
|
+
--head $(git branch --show-current)
|
|
90
|
+
|
|
91
|
+
# Or with labels and reviewers
|
|
92
|
+
gh pr create \
|
|
93
|
+
--title "Your PR Title" \
|
|
94
|
+
--body-file pr_description.md \
|
|
95
|
+
--label "enhancement" \
|
|
96
|
+
--reviewer @team-member \
|
|
97
|
+
--assignee @me
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
### 4. PR Review Checklist
|
|
101
|
+
|
|
102
|
+
**Code Quality:**
|
|
103
|
+
- [ ] No hardcoded credentials or secrets
|
|
104
|
+
- [ ] Error handling implemented
|
|
105
|
+
- [ ] Input validation in place
|
|
106
|
+
- [ ] Logging appropriate and not excessive
|
|
107
|
+
- [ ] No commented-out code blocks
|
|
108
|
+
|
|
109
|
+
**Testing:**
|
|
110
|
+
- [ ] Unit tests cover new code
|
|
111
|
+
- [ ] Integration tests updated
|
|
112
|
+
- [ ] Edge cases tested
|
|
113
|
+
- [ ] Error scenarios tested
|
|
114
|
+
|
|
115
|
+
**Documentation:**
|
|
116
|
+
- [ ] README updated if needed
|
|
117
|
+
- [ ] API docs updated
|
|
118
|
+
- [ ] Code comments for complex logic
|
|
119
|
+
- [ ] CHANGELOG updated
|
|
120
|
+
|
|
121
|
+
**Security:**
|
|
122
|
+
- [ ] No SQL injection vulnerabilities
|
|
123
|
+
- [ ] XSS prevention in place
|
|
124
|
+
- [ ] Authentication/authorization correct
|
|
125
|
+
- [ ] Dependencies have no known vulnerabilities
|
|
126
|
+
|
|
127
|
+
### 5. Managing PR
|
|
128
|
+
|
|
129
|
+
```bash
|
|
130
|
+
# Check PR status
|
|
131
|
+
gh pr status
|
|
132
|
+
|
|
133
|
+
# View PR details
|
|
134
|
+
gh pr view [pr-number]
|
|
135
|
+
|
|
136
|
+
# Add reviewers
|
|
137
|
+
gh pr edit [pr-number] --add-reviewer username
|
|
138
|
+
|
|
139
|
+
# Mark as ready for review
|
|
140
|
+
gh pr ready [pr-number]
|
|
141
|
+
|
|
142
|
+
# Merge PR (after approval)
|
|
143
|
+
gh pr merge [pr-number] --squash --delete-branch
|
|
144
|
+
|
|
145
|
+
# Or merge with merge commit
|
|
146
|
+
gh pr merge [pr-number] --merge --delete-branch
|
|
147
|
+
|
|
148
|
+
# Or rebase and merge
|
|
149
|
+
gh pr merge [pr-number] --rebase --delete-branch
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
## Common PR Scenarios
|
|
153
|
+
|
|
154
|
+
### Scenario 1: Feature PR
|
|
155
|
+
```bash
|
|
156
|
+
# From feature branch
|
|
157
|
+
git checkout -b feature/user-profile
|
|
158
|
+
# ... make changes ...
|
|
159
|
+
git add .
|
|
160
|
+
git commit -m "feat: Add user profile management"
|
|
161
|
+
git push -u origin feature/user-profile
|
|
162
|
+
gh pr create --title "feat: Add user profile management" --base main
|
|
163
|
+
```
|
|
164
|
+
|
|
165
|
+
### Scenario 2: Hotfix PR
|
|
166
|
+
```bash
|
|
167
|
+
git checkout -b hotfix/security-patch main
|
|
168
|
+
# ... fix critical issue ...
|
|
169
|
+
git commit -m "fix: Patch SQL injection vulnerability"
|
|
170
|
+
git push -u origin hotfix/security-patch
|
|
171
|
+
gh pr create --title "fix: Patch SQL injection vulnerability" --label "security,urgent" --base main
|
|
172
|
+
```
|
|
173
|
+
|
|
174
|
+
### Scenario 3: Update PR with Feedback
|
|
175
|
+
```bash
|
|
176
|
+
# Make requested changes
|
|
177
|
+
git add .
|
|
178
|
+
git commit -m "Address PR feedback: improve error handling"
|
|
179
|
+
git push
|
|
180
|
+
|
|
181
|
+
# Add comment to PR
|
|
182
|
+
gh pr comment [pr-number] --body "Updated with requested changes"
|
|
183
|
+
```
|
|
184
|
+
|
|
185
|
+
## Best Practices
|
|
186
|
+
|
|
187
|
+
1. **Keep PRs Small**: Aim for <400 lines of code changed
|
|
188
|
+
2. **Single Purpose**: One feature/fix per PR
|
|
189
|
+
3. **Clear Title**: Use conventional commit format
|
|
190
|
+
4. **Detailed Description**: Explain what, why, and how
|
|
191
|
+
5. **Self-Review First**: Review your own code before creating PR
|
|
192
|
+
6. **Update Branch**: Keep feature branch up-to-date with main
|
|
193
|
+
7. **Respond Quickly**: Address review comments promptly
|
|
194
|
+
8. **Clean Commits**: Squash fixup commits before merge
|
|
195
|
+
|
|
196
|
+
Execute the PR workflow based on the current repository state and task requirements.
|