-
Notifications
You must be signed in to change notification settings - Fork 1
133 lines (124 loc) · 4.64 KB
/
ui-dev-to-main-ci.yml
File metadata and controls
133 lines (124 loc) · 4.64 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
name: "CI UI - Development CI Feature Branch to Main"
on:
push:
branches:
- main
paths:
- ".github/**"
- "app/**"
- "Makefile"
pull_request:
branches:
- main
paths:
- ".github/**"
- "app/**"
- "Makefile"
workflow_call:
secrets:
AWS_ASSUME_ROLE:
required: true
permissions:
actions: read # Required for anchore/sbom-action
contents: write # Required for anchore/sbom-action
pull-requests: write
id-token: write # This is required for requesting the JWT
jobs:
react_testing_job:
name: Run UI Unit Tests
uses: ./.github/workflows/base-vitest-test.yml
with:
build_branch: ${{ github.event.pull_request.head.ref }}
cypress_build_job:
name: Build UI version for E2E Tests
uses: ./.github/workflows/base-cypress-build.yml
with:
build_branch: ${{ github.event.pull_request.head.ref }}
cypress_test_job:
name: Run Cypress E2E Tests
needs: [cypress_build_job]
uses: ./.github/workflows/base-cypress-test-all-env.yml
with:
cypress_base_url: ${{ vars.CYPRESS_BASE_URL }}
build_branch: ${{ github.event.pull_request.head.ref }}
deploy_ui:
name: Deploy UI
if: github.ref == 'refs/heads/main'
needs: ["react_testing_job", "cypress_test_job"]
uses: ./.github/workflows/base-deploy-ui.yml
with:
build_branch: ${{ github.event.pull_request.head.ref }}
environment: development
sandbox: ndr-dev
secrets:
AWS_ASSUME_ROLE: ${{ secrets.AWS_ASSUME_ROLE }}
notify-slack:
name: Notify Slack on Failure
runs-on: ubuntu-latest
environment: development
needs: [react_testing_job, cypress_build_job, cypress_test_job, deploy_ui]
if: failure() && github.event_name == 'push' && github.ref == 'refs/heads/main'
steps:
- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v5
with:
role-to-assume: ${{ secrets.AWS_ASSUME_ROLE }}
role-skip-session-tagging: true
aws-region: ${{ vars.AWS_REGION }}
mask-aws-account-id: true
- name: Get slack bot token from SSM parameter store
run: |
slack_bot_token=$(aws ssm get-parameter --name "/ndr/alerting/slack/bot_token" --with-decryption --query "Parameter.Value" --output text)
echo "::add-mask::$slack_bot_token"
echo "SLACK_BOT_TOKEN=$slack_bot_token" >> $GITHUB_ENV
- name: Send Slack Notification
uses: slackapi/slack-github-action@v2.1.1
with:
method: chat.postMessage
token: ${{ env.SLACK_BOT_TOKEN }}
payload: |
{
"channel": "${{ vars.ALERTS_SLACK_CHANNEL_ID }}",
"attachments": [
{
"color": "#ff0000",
"blocks": [
{
"type": "header",
"text": {
"type": "plain_text",
"text": "❌ Workflow `${{ github.workflow }}` failed"
}
},
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": "*Triggered by:* `${{ github.actor }}`\n*Workflow:* <${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}|${{ github.workflow }}>"
}
},
{
"type": "divider"
},
{
"type": "section",
"fields": [
{ "type": "mrkdwn", "text": "*react_testing_job:* ${{ needs.react_testing_job.result == 'success' && ':white_check_mark:' || ':x:' }}" },
{ "type": "mrkdwn", "text": "*cypress_build_job:* ${{ needs.cypress_build_job.result == 'success' && ':white_check_mark:' || ':x:' }}" },
{ "type": "mrkdwn", "text": "*cypress_test_job:* ${{ needs.cypress_test_job.result == 'success' && ':white_check_mark:' || ':x:' }}" },
{ "type": "mrkdwn", "text": "*deploy_ui:* ${{ needs.deploy_ui.result == 'success' && ':white_check_mark:' || ':x:' }}" }
]
},
{
"type": "context",
"elements": [
{
"type": "mrkdwn",
"text": "Environment: `development` | Sandbox: `ndr-dev`"
}
]
}
]
}
]
}