-
Notifications
You must be signed in to change notification settings - Fork 6
267 lines (242 loc) · 9.88 KB
/
Copy pathdeploy-all.yml
File metadata and controls
267 lines (242 loc) · 9.88 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
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
# Deploy to All Cloud Providers in Parallel
#
# This workflow orchestrates deployment to multiple cloud providers simultaneously.
# Useful for disaster recovery, multi-cloud redundancy, or testing across platforms.
#
# Required GitHub Secrets:
# - All secrets from individual deployment workflows (AWS, GCP, Azure)
#
# Required GitHub Variables:
# - All variables from individual deployment workflows
#
# Triggered by:
# - Manual workflow dispatch
# - Release creation (deploys to prod across all clouds)
name: Deploy to All Clouds
on:
workflow_dispatch:
inputs:
environment:
description: 'Environment to deploy to'
required: true
type: choice
options:
- dev
- staging
- prod
deploy_to:
description: 'Cloud providers to deploy to'
required: true
type: choice
options:
- all
- aws-only
- gcp-only
- azure-only
- aws-gcp
- aws-azure
- gcp-azure
release:
types: [created]
jobs:
# Determine deployment strategy
determine-deployment:
name: Determine Deployment Strategy
runs-on: ubuntu-latest
outputs:
environment: ${{ steps.set-env.outputs.environment }}
deploy-aws-lambda: ${{ steps.set-clouds.outputs.deploy-aws-lambda }}
deploy-aws-fargate: ${{ steps.set-clouds.outputs.deploy-aws-fargate }}
deploy-gcp: ${{ steps.set-clouds.outputs.deploy-gcp }}
deploy-azure: ${{ steps.set-clouds.outputs.deploy-azure }}
steps:
- name: Set environment
id: set-env
run: |
if [[ "${{ github.event_name }}" == "release" ]]; then
echo "environment=prod" >> $GITHUB_OUTPUT
else
echo "environment=${{ inputs.environment }}" >> $GITHUB_OUTPUT
fi
- name: Set cloud providers
id: set-clouds
run: |
DEPLOY_TO="${{ inputs.deploy_to || 'all' }}"
# AWS Lambda
if [[ "$DEPLOY_TO" == "all" ]] || \
[[ "$DEPLOY_TO" == "aws-only" ]] || \
[[ "$DEPLOY_TO" == "aws-gcp" ]] || \
[[ "$DEPLOY_TO" == "aws-azure" ]]; then
echo "deploy-aws-lambda=true" >> $GITHUB_OUTPUT
else
echo "deploy-aws-lambda=false" >> $GITHUB_OUTPUT
fi
# AWS Fargate (optional, can be enabled separately)
echo "deploy-aws-fargate=false" >> $GITHUB_OUTPUT
# GCP
if [[ "$DEPLOY_TO" == "all" ]] || \
[[ "$DEPLOY_TO" == "gcp-only" ]] || \
[[ "$DEPLOY_TO" == "aws-gcp" ]] || \
[[ "$DEPLOY_TO" == "gcp-azure" ]]; then
echo "deploy-gcp=true" >> $GITHUB_OUTPUT
else
echo "deploy-gcp=false" >> $GITHUB_OUTPUT
fi
# Azure
if [[ "$DEPLOY_TO" == "all" ]] || \
[[ "$DEPLOY_TO" == "azure-only" ]] || \
[[ "$DEPLOY_TO" == "aws-azure" ]] || \
[[ "$DEPLOY_TO" == "gcp-azure" ]]; then
echo "deploy-azure=true" >> $GITHUB_OUTPUT
else
echo "deploy-azure=false" >> $GITHUB_OUTPUT
fi
- name: Display deployment plan
run: |
echo "## Deployment Plan" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "**Environment:** ${{ steps.set-env.outputs.environment }}" >> $GITHUB_STEP_SUMMARY
echo "**Deploy Strategy:** ${{ inputs.deploy_to || 'all' }}" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "### Clouds" >> $GITHUB_STEP_SUMMARY
echo "- AWS Lambda: ${{ steps.set-clouds.outputs.deploy-aws-lambda }}" >> $GITHUB_STEP_SUMMARY
echo "- AWS Fargate: ${{ steps.set-clouds.outputs.deploy-aws-fargate }}" >> $GITHUB_STEP_SUMMARY
echo "- GCP Cloud Run: ${{ steps.set-clouds.outputs.deploy-gcp }}" >> $GITHUB_STEP_SUMMARY
echo "- Azure Container Apps: ${{ steps.set-clouds.outputs.deploy-azure }}" >> $GITHUB_STEP_SUMMARY
# Deploy to AWS Lambda
deploy-aws-lambda:
name: Deploy AWS Lambda
needs: determine-deployment
if: needs.determine-deployment.outputs.deploy-aws-lambda == 'true'
uses: ./.github/workflows/deploy-aws-lambda.yml
with:
environment: ${{ needs.determine-deployment.outputs.environment }}
secrets:
ADMIN_EMAIL: ${{ secrets.ADMIN_EMAIL }}
DASHBOARD_URL: ${{ secrets.DASHBOARD_URL }}
FROM_EMAIL: ${{ secrets.FROM_EMAIL }}
TF_BACKEND_AWS: ${{ secrets.TF_BACKEND_AWS }}
# Deploy to AWS Fargate
deploy-aws-fargate:
name: Deploy AWS Fargate
needs: determine-deployment
if: needs.determine-deployment.outputs.deploy-aws-fargate == 'true'
uses: ./.github/workflows/deploy-aws-fargate.yml
with:
environment: ${{ needs.determine-deployment.outputs.environment }}
secrets:
ADMIN_EMAIL: ${{ secrets.ADMIN_EMAIL }}
TF_BACKEND_AWS: ${{ secrets.TF_BACKEND_AWS }}
# Deploy to GCP Cloud Run
deploy-gcp:
name: Deploy GCP Cloud Run
needs: determine-deployment
if: needs.determine-deployment.outputs.deploy-gcp == 'true'
uses: ./.github/workflows/deploy-gcp.yml
with:
environment: ${{ needs.determine-deployment.outputs.environment }}
secrets:
ADMIN_EMAIL: ${{ secrets.ADMIN_EMAIL }}
TF_BACKEND_GCP: ${{ secrets.TF_BACKEND_GCP }}
# Deploy to Azure Container Apps
deploy-azure:
name: Deploy Azure Container Apps
needs: determine-deployment
if: needs.determine-deployment.outputs.deploy-azure == 'true'
uses: ./.github/workflows/deploy-azure.yml
with:
environment: ${{ needs.determine-deployment.outputs.environment }}
secrets:
ADMIN_EMAIL: ${{ secrets.ADMIN_EMAIL }}
AZURE_CLIENT_ID: ${{ secrets.AZURE_CLIENT_ID }}
AZURE_SUBSCRIPTION_ID: ${{ secrets.AZURE_SUBSCRIPTION_ID }}
AZURE_TENANT_ID: ${{ secrets.AZURE_TENANT_ID }}
TF_BACKEND_AZURE: ${{ secrets.TF_BACKEND_AZURE }}
# Aggregate results and notify
notify:
name: Deployment Results
needs:
- determine-deployment
- deploy-aws-lambda
- deploy-aws-fargate
- deploy-gcp
- deploy-azure
if: always()
runs-on: ubuntu-latest
steps:
- name: Aggregate results
run: |
echo "## Multi-Cloud Deployment Results" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "**Environment:** ${{ needs.determine-deployment.outputs.environment }}" >> $GITHUB_STEP_SUMMARY
echo "**Timestamp:** $(date -u +%Y-%m-%dT%H:%M:%SZ)" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "### Deployment Status" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
# AWS Lambda
if [[ "${{ needs.determine-deployment.outputs.deploy-aws-lambda }}" == "true" ]]; then
if [[ "${{ needs.deploy-aws-lambda.result }}" == "success" ]]; then
echo "- ✅ AWS Lambda: Success" >> $GITHUB_STEP_SUMMARY
else
echo "- ❌ AWS Lambda: ${{ needs.deploy-aws-lambda.result }}" >> $GITHUB_STEP_SUMMARY
fi
else
echo "- ⏭️ AWS Lambda: Skipped" >> $GITHUB_STEP_SUMMARY
fi
# AWS Fargate
if [[ "${{ needs.determine-deployment.outputs.deploy-aws-fargate }}" == "true" ]]; then
if [[ "${{ needs.deploy-aws-fargate.result }}" == "success" ]]; then
echo "- ✅ AWS Fargate: Success" >> $GITHUB_STEP_SUMMARY
else
echo "- ❌ AWS Fargate: ${{ needs.deploy-aws-fargate.result }}" >> $GITHUB_STEP_SUMMARY
fi
else
echo "- ⏭️ AWS Fargate: Skipped" >> $GITHUB_STEP_SUMMARY
fi
# GCP
if [[ "${{ needs.determine-deployment.outputs.deploy-gcp }}" == "true" ]]; then
if [[ "${{ needs.deploy-gcp.result }}" == "success" ]]; then
echo "- ✅ GCP Cloud Run: Success" >> $GITHUB_STEP_SUMMARY
else
echo "- ❌ GCP Cloud Run: ${{ needs.deploy-gcp.result }}" >> $GITHUB_STEP_SUMMARY
fi
else
echo "- ⏭️ GCP Cloud Run: Skipped" >> $GITHUB_STEP_SUMMARY
fi
# Azure
if [[ "${{ needs.determine-deployment.outputs.deploy-azure }}" == "true" ]]; then
if [[ "${{ needs.deploy-azure.result }}" == "success" ]]; then
echo "- ✅ Azure Container Apps: Success" >> $GITHUB_STEP_SUMMARY
else
echo "- ❌ Azure Container Apps: ${{ needs.deploy-azure.result }}" >> $GITHUB_STEP_SUMMARY
fi
else
echo "- ⏭️ Azure Container Apps: Skipped" >> $GITHUB_STEP_SUMMARY
fi
- name: Check for failures
run: |
FAILED=false
if [[ "${{ needs.deploy-aws-lambda.result }}" == "failure" ]] || \
[[ "${{ needs.deploy-aws-fargate.result }}" == "failure" ]] || \
[[ "${{ needs.deploy-gcp.result }}" == "failure" ]] || \
[[ "${{ needs.deploy-azure.result }}" == "failure" ]]; then
FAILED=true
fi
if [ "$FAILED" = true ]; then
echo "" >> $GITHUB_STEP_SUMMARY
echo "❌ **One or more deployments failed. Check individual job logs.**" >> $GITHUB_STEP_SUMMARY
exit 1
else
echo "" >> $GITHUB_STEP_SUMMARY
echo "✅ **All deployments completed successfully!**" >> $GITHUB_STEP_SUMMARY
fi
# Optional: Send notification to Slack, Discord, email, etc.
# - name: Send notification
# if: always()
# uses: slackapi/slack-github-action@91efab103c0de0a537f72a35f6b8cda0ee76bf0a # v2.1.1
# with:
# method: chat.postMessage
# token: ${{ secrets.SLACK_BOT_TOKEN }}
# payload: |
# channel: ${{ secrets.SLACK_CHANNEL_ID }}
# text: "Multi-cloud deployment to ${{ needs.determine-deployment.outputs.environment }}: ${{ job.status }}"