forked from PinSpace-Org/GistPin
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmonthly-dr-test.yml
More file actions
103 lines (91 loc) · 3.54 KB
/
Copy pathmonthly-dr-test.yml
File metadata and controls
103 lines (91 loc) · 3.54 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
name: Monthly DR Test
on:
schedule:
# Run at 06:00 UTC on the 1st of every month
- cron: '0 6 1 * *'
workflow_dispatch:
inputs:
dr_region:
description: 'DR region to test'
required: true
default: 'us-west-2'
type: string
primary_region:
description: 'Primary region'
required: true
default: 'us-east-1'
type: string
env:
PRIMARY_REGION: ${{ inputs.primary_region || 'us-east-1' }}
DR_REGION: ${{ inputs.dr_region || 'us-west-2' }}
NAMESPACE: gistpin
jobs:
dr-test:
name: Run DR Test
runs-on: ubuntu-latest
permissions:
contents: read
id-token: write
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v4
with:
role-to-assume: ${{ secrets.AWS_DR_TEST_ROLE_ARN }}
aws-region: ${{ env.DR_REGION }}
role-duration-seconds: 3600
- name: Set up kubectl
uses: azure/setup-kubectl@v4
with:
version: 'latest'
- name: Run DR test script
id: dr-test
run: |
bash infrastructure/scripts/dr-test-runner.sh \
--primary-region "${PRIMARY_REGION}" \
--dr-region "${DR_REGION}" \
--namespace "${NAMESPACE}" \
--rto 900 \
--rpo 300
continue-on-error: true
- name: Archive DR test results
if: always()
uses: actions/upload-artifact@v4
with:
name: dr-test-results-${{ github.run_id }}
path: /tmp/dr-test-runner-*.txt
retention-days: 365
- name: Upload DR test report
if: always()
uses: actions/upload-artifact@v4
with:
name: dr-test-report-${{ github.run_id }}
path: /tmp/dr-test-runner-*.txt
retention-days: 365
- name: Notify on failure
if: steps.dr-test.outcome == 'failure'
uses: slackapi/slack-github-action@v1
with:
slack-message: "❌ *DR Test Failed* — ${{ github.repository }}/${{ github.run_id }}\nPrimary: ${{ env.PRIMARY_REGION }} | DR: ${{ env.DR_REGION }}\nRTO target: 900s | RPO target: 300s\nView details: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}"
env:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
- name: Notify on success
if: steps.dr-test.outcome == 'success'
uses: slackapi/slack-github-action@v1
with:
slack-message: "✓ *DR Test Passed* — ${{ github.repository }}/${{ github.run_id }}\nPrimary: ${{ env.PRIMARY_REGION }} | DR: ${{ env.DR_REGION }}\nAll RTO/RPO targets met."
env:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
- name: Create GitHub issue on failure
if: steps.dr-test.outcome == 'failure'
uses: actions/github-script@v7
with:
script: |
github.rest.issues.create({
owner: context.repo.owner,
repo: context.repo.repo,
title: `DR Test Failed — ${context.runId}`,
body: `## Disaster Recovery Test Failure\n\n**Run**: ${context.serverUrl}/${context.repo.owner}/${context.repo.repo}/actions/runs/${context.runId}\n**Primary Region**: ${process.env.PRIMARY_REGION}\n**DR Region**: ${process.env.DR_REGION}\n**Date**: ${new Date().toISOString()}\n\nThe monthly DR test has failed. Review the test report and take corrective action.`,
labels: ['dr-test', 'critical']
})