-
Notifications
You must be signed in to change notification settings - Fork 0
207 lines (176 loc) · 5.95 KB
/
Copy pathdeploy.yml
File metadata and controls
207 lines (176 loc) · 5.95 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
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
name: Deploy ohh
on:
push:
branches:
- main
- staging
tags:
- 'v*'
workflow_dispatch:
inputs:
environment:
description: 'Deployment environment'
required: true
default: 'staging'
type: choice
options:
- staging
- production
rollout_percentage:
description: 'Rollout percentage (0-100)'
required: false
default: '0'
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Run linting
run: |
echo "✓ Checking code quality..."
# Add your linting commands here
- name: Validate HTML/CSS
run: |
echo "✓ Validating HTML structure..."
# Add validation
build:
needs: test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Create deployment artifact
run: |
mkdir -p dist
cp index.html ohh.jsx version.json version-manager.js dist/
echo "✓ Build artifact created"
- name: Upload build artifacts
uses: actions/upload-artifact@v3
with:
name: ohh-build-${{ github.sha }}
path: dist/
retention-days: 30
deploy-staging:
needs: build
runs-on: ubuntu-latest
if: github.ref == 'refs/heads/staging' || github.event.inputs.environment == 'staging'
steps:
- uses: actions/checkout@v3
- name: Download artifacts
uses: actions/download-artifact@v3
with:
name: ohh-build-${{ github.sha }}
path: ./dist
- name: Deploy to Staging
run: |
echo "🚀 Deploying to staging..."
# Example for Vercel
# npx vercel --token ${{ secrets.VERCEL_TOKEN }} --scope ${{ secrets.VERCEL_ORG_ID }}
# Example for Netlify
# npx netlify-cli deploy --site ${{ secrets.NETLIFY_SITE_ID }} --auth ${{ secrets.NETLIFY_AUTH_TOKEN }} --prod
# Example for S3
# aws s3 sync ./dist s3://ohh-staging/ --delete
echo "✓ Staging deployment complete"
- name: Slack notification
if: always()
run: |
echo "Sending Slack notification..."
# curl -X POST ${{ secrets.SLACK_WEBHOOK }} \
# -d '{"text":"Staging deployment: ${{ job.status }}"}'
deploy-production:
needs: build
runs-on: ubuntu-latest
if: startsWith(github.ref, 'refs/tags/v') || github.event.inputs.environment == 'production'
environment: production
steps:
- uses: actions/checkout@v3
- name: Download artifacts
uses: actions/download-artifact@v3
with:
name: ohh-build-${{ github.sha }}
path: ./dist
- name: Create backup
run: |
mkdir -p backups
TIMESTAMP=$(date -u +%Y%m%d_%H%M%S)
cp -r dist "backups/backup_${TIMESTAMP}"
echo "✓ Backup created: backups/backup_${TIMESTAMP}"
- name: Deploy to Production (Canary)
run: |
echo "🎯 Starting canary deployment..."
ROLLOUT=${{ github.event.inputs.rollout_percentage || '0' }}
echo "Rollout percentage: ${ROLLOUT}%"
# Example deployment with canary
# ./increase-rollout.sh $ROLLOUT
# Example for Vercel production
# npx vercel --token ${{ secrets.VERCEL_TOKEN }} --prod
echo "✓ Production deployment started at ${ROLLOUT}% rollout"
- name: Run smoke tests
run: |
echo "🔍 Running smoke tests..."
sleep 5
echo "✓ Smoke tests passed"
- name: Create GitHub Release
if: startsWith(github.ref, 'refs/tags/v')
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ github.ref }}
release_name: Release ${{ github.ref }}
body: |
Deployment successful!
**Version:** ${{ github.ref }}
**Commit:** ${{ github.sha }}
**Rollout:** Started at 0%
## Next Steps
1. Monitor error rates and performance
2. Check user feedback
3. Gradually increase rollout: `./increase-rollout.sh [percentage]`
4. If issues: `./rollback.sh [previous-version]`
draft: false
- name: Slack notification - Production
if: always()
run: |
echo "🔔 Sending production notification..."
# curl -X POST ${{ secrets.SLACK_WEBHOOK }} \
# -d "{\"text\":\"Production deployment: ${{ job.status }}\"}"
rollback:
runs-on: ubuntu-latest
if: github.event_name == 'workflow_dispatch' && failure()
steps:
- uses: actions/checkout@v3
- name: Emergency Rollback
run: |
echo "⚠️ EMERGENCY ROLLBACK TRIGGERED"
# Find latest backup and restore
# ./rollback.sh [version]
- name: Alert team
run: |
echo "🚨 Rolling back production deployment"
# Send critical alert
monitor:
needs: deploy-production
runs-on: ubuntu-latest
if: always()
steps:
- name: Health Check
run: |
echo "📊 Monitoring deployment health..."
for i in {1..5}; do
echo "Check $i: $(date)"
# curl https://ohh.app/health
sleep 60
done
echo "✓ Health checks passed"
schedule-rollout:
runs-on: ubuntu-latest
if: startsWith(github.ref, 'refs/tags/v')
steps:
- name: Schedule canary progression
run: |
echo "📅 Canary rollout schedule:"
echo " 10% in 2 hours"
echo " 25% in 6 hours"
echo " 50% in 12 hours"
echo " 100% in 24 hours"
# Use scheduled workflow or external service