Skip to content

Commit 2a695f0

Browse files
committed
[PRMP-631] Buffer between destory and spinup
1 parent 631f905 commit 2a695f0

File tree

2 files changed

+133
-19
lines changed

2 files changed

+133
-19
lines changed

.github/workflows/cron-daily-health-check.yml renamed to .github/workflows/cron-daily-health-check-spinup.yml

Lines changed: 28 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
name: 'Z-CRON: Daily health check'
1+
name: "Z-CRON: Daily health check - Spinup"
22

33
on:
44
schedule:
55
- cron: 30 4 * * 1-5
66

77
permissions:
8-
actions: read # Required for anchore/sbom-action
8+
actions: read # Required for anchore/sbom-action
99
contents: write # Required for anchore/sbom-action
1010
pull-requests: write
1111
id-token: write
@@ -19,13 +19,13 @@ jobs:
1919
steps:
2020
- name: Set Output
2121
id: set-output
22-
run: echo 'workspace=ndrd' >> $GITHUB_OUTPUT
22+
run: echo 'workspace=ndrd' >> $GITHUB_OUTPUT
2323

2424
terraform_plan_apply:
2525
name: Terraform Plan/Apply (ndrd)
2626
runs-on: ubuntu-latest
2727
environment: development
28-
needs: ['set_workspace']
28+
needs: ["set_workspace"]
2929
steps:
3030
- name: Checkout
3131
uses: actions/checkout@v5
@@ -79,7 +79,7 @@ jobs:
7979
with:
8080
python_version: "3.11"
8181
build_branch: main
82-
82+
8383
run_ui_unit_tests:
8484
name: Run UI Unit Tests
8585
uses: NHSDigital/national-document-repository/.github/workflows/base-vitest-test.yml@main
@@ -88,7 +88,7 @@ jobs:
8888

8989
run_cypress_tests:
9090
name: Run Cypress Tests
91-
runs-on: ubuntu-latest
91+
runs-on: ubuntu-latest
9292
steps:
9393
- name: Checkout
9494
uses: actions/checkout@v5
@@ -107,9 +107,9 @@ jobs:
107107
IDENTITY_PROVIDER_POOL_ID: not provided yet
108108
MONITOR_ACCOUNT_ID: not provided yet
109109
BUILD_ENV: development
110-
IMAGE_VERSION: 'not-required'
110+
IMAGE_VERSION: "not-required"
111111
run: |
112-
./react-environment-config.sh
112+
./react-environment-config.sh
113113
working-directory: ./app
114114

115115
- name: Cypress Build
@@ -119,7 +119,7 @@ jobs:
119119
runTests: false
120120
build: npm run build
121121
working-directory: ./app
122-
122+
123123
- name: npm install serve -g
124124
run: npm install serve -g
125125

@@ -132,8 +132,8 @@ jobs:
132132
working-directory: ./app
133133
env:
134134
CYPRESS_BASE_URL: http://localhost:3000
135-
CYPRESS_grepTags: 'regression'
136-
135+
CYPRESS_grepTags: "regression"
136+
137137
- name: Upload Artifacts (Screenshots)
138138
uses: actions/upload-artifact@v4
139139
if: failure()
@@ -152,7 +152,7 @@ jobs:
152152

153153
publish_lambda_layers:
154154
name: Publish Lambda Layers
155-
needs: ['set_workspace', 'terraform_plan_apply']
155+
needs: ["set_workspace", "terraform_plan_apply"]
156156
uses: NHSDigital/national-document-repository/.github/workflows/base-lambda-layer-reusable-publish-all.yml@main
157157
with:
158158
build_branch: main
@@ -161,11 +161,11 @@ jobs:
161161
python_version: "3.11"
162162
secrets:
163163
AWS_ASSUME_ROLE: ${{ secrets.AWS_ASSUME_ROLE }}
164-
164+
165165
deploy_lambdas:
166166
name: Deploy Lambdas
167167
uses: NHSDigital/national-document-repository/.github/workflows/base-lambdas-reusable-deploy-all.yml@main
168-
needs: ['set_workspace', 'publish_lambda_layers']
168+
needs: ["set_workspace", "publish_lambda_layers"]
169169
with:
170170
build_branch: main
171171
sandbox: ${{ needs.set_workspace.outputs.workspace }}
@@ -178,7 +178,7 @@ jobs:
178178
deploy_ui:
179179
name: Deploy UI
180180
uses: NHSDigital/national-document-repository/.github/workflows/base-deploy-ui.yml@main
181-
needs: ['terraform_plan_apply', 'set_workspace']
181+
needs: ["terraform_plan_apply", "set_workspace"]
182182
with:
183183
build_branch: main
184184
sandbox: ${{ needs.set_workspace.outputs.workspace }}
@@ -188,8 +188,8 @@ jobs:
188188

189189
destroy_test_environment:
190190
if: always()
191-
name: Destroy Sandbox (ndrd)
192-
needs: ['set_workspace', 'deploy_ui', 'deploy_lambdas']
191+
name: Destroy Sandbox (ndrd)
192+
needs: ["set_workspace", "deploy_ui", "deploy_lambdas"]
193193
uses: ./.github/workflows/tear-down-sandbox.yml
194194
with:
195195
git_ref: main
@@ -201,7 +201,16 @@ jobs:
201201
name: Notify Slack on Failure
202202
runs-on: ubuntu-latest
203203
environment: development
204-
needs: [terraform_plan_apply, run_lambda_unit_tests, run_ui_unit_tests, run_cypress_tests, publish_lambda_layers, deploy_lambdas, deploy_ui]
204+
needs:
205+
[
206+
terraform_plan_apply,
207+
run_lambda_unit_tests,
208+
run_ui_unit_tests,
209+
run_cypress_tests,
210+
publish_lambda_layers,
211+
deploy_lambdas,
212+
deploy_ui,
213+
]
205214
if: failure()
206215
steps:
207216
- name: Configure AWS Credentials
@@ -268,4 +277,4 @@ jobs:
268277
]
269278
}
270279
]
271-
}
280+
}
Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
1+
name: "Z-CRON: Daily health check - Teardown"
2+
3+
on:
4+
schedule:
5+
- cron: 30 6 * * 1-5
6+
7+
permissions:
8+
actions: read # Required for anchore/sbom-action
9+
contents: write # Required for anchore/sbom-action
10+
pull-requests: write
11+
id-token: write
12+
13+
jobs:
14+
set_workspace:
15+
name: Set Workspace (ndrd)
16+
runs-on: ubuntu-latest
17+
outputs:
18+
workspace: ${{ steps.set-output.outputs.workspace }}
19+
steps:
20+
- name: Set Output
21+
id: set-output
22+
run: echo 'workspace=ndrd' >> $GITHUB_OUTPUT
23+
24+
destroy_test_environment:
25+
name: Destroy Sandbox (ndrd)
26+
needs: ["set_workspace", "deploy_ui", "deploy_lambdas"]
27+
uses: ./.github/workflows/tear-down-sandbox.yml
28+
with:
29+
git_ref: main
30+
sandbox_name: ${{ needs.set_workspace.outputs.workspace }}
31+
environment: development
32+
secrets: inherit
33+
34+
notify-slack:
35+
name: Notify Slack on Failure
36+
runs-on: ubuntu-latest
37+
environment: development
38+
needs: [destroy_test_environment]
39+
if: failure()
40+
steps:
41+
- name: Configure AWS Credentials
42+
uses: aws-actions/configure-aws-credentials@v5
43+
with:
44+
role-to-assume: ${{ secrets.AWS_ASSUME_ROLE }}
45+
role-skip-session-tagging: true
46+
aws-region: ${{ vars.AWS_REGION }}
47+
mask-aws-account-id: true
48+
49+
- name: Get slack bot token from SSM parameter store
50+
run: |
51+
slack_bot_token=$(aws ssm get-parameter --name "/ndr/alerting/slack/bot_token" --with-decryption --query "Parameter.Value" --output text)
52+
echo "::add-mask::$slack_bot_token"
53+
echo "SLACK_BOT_TOKEN=$slack_bot_token" >> $GITHUB_ENV
54+
55+
- name: Send Slack Notification
56+
uses: slackapi/slack-github-action@v2.1.1
57+
with:
58+
method: chat.postMessage
59+
token: ${{ env.SLACK_BOT_TOKEN }}
60+
payload: |
61+
{
62+
"channel": "${{ vars.ALERTS_SLACK_CHANNEL_ID }}",
63+
"attachments": [
64+
{
65+
"color": "#ff0000",
66+
"blocks": [
67+
{
68+
"type": "header",
69+
"text": {
70+
"type": "plain_text",
71+
"text": "❌ Workflow `${{ github.workflow }}` failed"
72+
}
73+
},
74+
{
75+
"type": "section",
76+
"text": {
77+
"type": "mrkdwn",
78+
"text": "*Triggered by:* `Scheduled Job`\n*Workflow:* <${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}|${{ github.workflow }}>"
79+
}
80+
},
81+
{
82+
"type": "divider"
83+
},
84+
{
85+
"type": "section",
86+
"fields": [
87+
{ "type": "mrkdwn", "text": "*terraform_plan_apply:* ${{ needs.terraform_plan_apply.result == 'success' && ':white_check_mark:' || ':x:' }}" },
88+
{ "type": "mrkdwn", "text": "*run_lambda_unit_tests:* ${{ needs.run_lambda_unit_tests.result == 'success' && ':white_check_mark:' || ':x:' }}" },
89+
{ "type": "mrkdwn", "text": "*run_ui_unit_tests:* ${{ needs.run_ui_unit_tests.result == 'success' && ':white_check_mark:' || ':x:' }}" },
90+
{ "type": "mrkdwn", "text": "*run_cypress_tests:* ${{ needs.run_cypress_tests.result == 'success' && ':white_check_mark:' || ':x:' }}" },
91+
{ "type": "mrkdwn", "text": "*publish_lambda_layers:* ${{ needs.publish_lambda_layers.result == 'success' && ':white_check_mark:' || ':x:' }}" },
92+
{ "type": "mrkdwn", "text": "*deploy_lambdas:* ${{ needs.deploy_lambdas.result == 'success' && ':white_check_mark:' || ':x:' }}" },
93+
{ "type": "mrkdwn", "text": "*deploy_ui:* ${{ needs.deploy_ui.result == 'success' && ':white_check_mark:' || ':x:' }}" }
94+
]
95+
},
96+
{
97+
"type": "context",
98+
"elements": [
99+
{ "type": "mrkdwn", "text": "Environment: `development` | Sandbox: `${{ needs.set_workspace.outputs.workspace }}`" }
100+
]
101+
}
102+
]
103+
}
104+
]
105+
}

0 commit comments

Comments
 (0)