-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdeployment.yml
More file actions
127 lines (110 loc) · 4.01 KB
/
deployment.yml
File metadata and controls
127 lines (110 loc) · 4.01 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
name: Deploy to Production
on:
workflow_dispatch:
inputs:
environment:
description: "Environment to deploy to"
required: true
type: choice
options:
- staging
- production
default: "staging"
deployment_outcome:
description: "Deployment outcome to simulate"
required: true
type: choice
options:
- success
- failure
default: "success"
permissions:
deployments: write
contents: read
jobs:
deploy:
runs-on: ubuntu-latest
environment: ${{ inputs.environment || 'staging' }}
steps:
- name: Validate prerequisites
run: |
if [[ -z "${{ secrets.INCIDENT_IO_API_KEY }}" ]] || [[ -z "${{ secrets.INCIDENT_IO_ALERT_SOURCE_ID }}" ]]; then
echo "❌ Missing required secrets for incident.io integration"
echo " 👉 Fix: See docs/SETUP.md Step 4"
exit 1
fi
echo "✅ Prerequisites validated"
- name: Checkout code
uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: "20"
cache: "npm"
- name: Install dependencies
run: npm ci
- name: Build application
run: npm run build
- name: Deploy
id: deploy
env:
DEPLOYMENT_OUTCOME: ${{ inputs.deployment_outcome }}
run: |
./scripts/deploy.sh ${{ inputs.environment || 'staging' }}
continue-on-error: true
- name: Set deployment status
id: deployment-status
run: |
if [ "${{ steps.deploy.outcome }}" = "success" ]; then
echo "status=success" >> $GITHUB_OUTPUT
else
echo "status=failure" >> $GITHUB_OUTPUT
fi
- name: Alert on Production Deployment Failure
if: |
steps.deploy.outcome == 'failure' &&
inputs.environment == 'production'
uses: incident-io/github-action@v0
with:
api-key: ${{ secrets.INCIDENT_IO_API_KEY }}
alert-source-id: ${{ secrets.INCIDENT_IO_ALERT_SOURCE_ID }}
alert-title: "Production Deployment Failed: ${{ github.repository }}"
alert-description: |
🚨 **CRITICAL**: Production deployment has failed and requires immediate attention.
**Environment:** ${{ inputs.environment }}
**Status:** failure
**Deployed by:** ${{ github.actor }}
**Branch:** ${{ github.ref_name }}
**Commit:** ${{ github.sha }}
**Run:** ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}
**Immediate Actions:**
1. Review deployment logs for errors
2. Assess if rollback is needed
3. Check production health metrics
4. Notify on-call team if customer impact detected
**Rollback Available:** Yes - run `./scripts/rollback.sh`
severity: "critical"
deduplication-key: "deploy-${{ inputs.environment }}"
custom-fields: |
{
"service": "payment-api",
"team": "payments-team",
"environment": "${{ inputs.environment }}",
"deployment_id": "${{ github.run_id }}",
"deployed_by": "${{ github.actor }}",
"requires_immediate_response": true
}
- name: Resolve alert on successful deployment
if: |
steps.deploy.outcome == 'success' &&
inputs.environment == 'production'
uses: incident-io/github-action@v0
with:
api-key: ${{ secrets.INCIDENT_IO_API_KEY }}
alert-source-id: ${{ secrets.INCIDENT_IO_ALERT_SOURCE_ID }}
alert-title: "Production Deployment Failed: ${{ github.repository }}"
alert-status: "resolved"
deduplication-key: "deploy-${{ inputs.environment }}"
- name: Fail job if deployment failed
if: steps.deploy.outcome == 'failure'
run: exit 1