-
Notifications
You must be signed in to change notification settings - Fork 2
120 lines (106 loc) · 3.93 KB
/
deploy-dashboard-dev.yml
File metadata and controls
120 lines (106 loc) · 3.93 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
name: Deploy Dashboard - Dev
on:
workflow_dispatch:
workflow_call:
permissions:
pull-requests: write
id-token: write
contents: read
jobs:
build-and-publish-ui:
environment: dev
runs-on: ubuntu-latest
defaults:
run:
working-directory: ./dashboard
steps:
- name: Checkout repo
uses: actions/checkout@v6
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v6
with:
mask-aws-account-id: true
role-to-assume: ${{ secrets.AWS_ASSUME_ROLE }}
role-skip-session-tagging: true
aws-region: ${{ vars.AWS_REGION }}
- name: Login to Amazon ECR
id: login-ecr
uses: aws-actions/amazon-ecr-login@v2
- name: Get ECR repository URI from SSM
id: ecr-repo
run: |
uri=$(aws ssm get-parameter \
--name "/registrations/${{ vars.AWS_ENVIRONMENT }}/data-pipeline/ecr/url/gp2gp-dashboard" \
--query "Parameter.Value" --output text)
echo "::add-mask::$uri"
echo "uri=$uri" >> $GITHUB_OUTPUT
- name: Use Node.js 24.x
uses: actions/setup-node@v6
with:
node-version: 24.x
cache: "npm"
cache-dependency-path: dashboard/package-lock.json
- name: Install dependencies
run: npm ci
- name: Build and Push Docker Image
env:
REF_NAME: ${{ github.ref_name }}
ECR_URI: ${{ steps.ecr-repo.outputs.uri }}
IMAGE_TAG: ${{ github.sha }}
run: |
TAG_ARGS=(-t "$ECR_URI:$IMAGE_TAG" -t "$ECR_URI:latest")
if [ -n "${REF_NAME:-}" ]; then
REF_TAG="${REF_NAME//\//-}"
TAG_ARGS+=(-t "$ECR_URI:$REF_TAG")
fi
docker build "${TAG_ARGS[@]}" --build-arg BUILD_TAG="$IMAGE_TAG" .
docker push "$ECR_URI:$IMAGE_TAG"
docker push "$ECR_URI:latest"
if [ -n "${GITHUB_REF_NAME:-}" ]; then
REF_TAG="${GITHUB_REF_NAME//\//-}"
docker push "$ECR_URI:$REF_TAG"
fi
redeploy_gp2gp_infrastructure_dashboard:
name: Redeploy gp2gp infrastructure dashboard
needs: [build-and-publish-ui]
uses: NHSDigital/gp2gp-reporting-infrastructure/.github/workflows/deploy-stack.yml@v4
with:
environment: dev
is_deployment: ${{ github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/') }}
terraform_stack: gp2gp_dashboard
has_image: true
hyphenated_alias: gp2gp-dashboard
build_lambda: true
secrets: inherit
redeploy_gp2gp_infrastructure_step_functions:
name: Redeploy gp2gp infrastructure step functions
needs: [redeploy_gp2gp_infrastructure_dashboard]
uses: NHSDigital/gp2gp-reporting-infrastructure/.github/workflows/deploy-stack.yml@v4
with:
environment: dev
is_deployment: ${{ github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/') }}
terraform_stack: step_function
hyphenated_alias: step-function
secrets: inherit
dashboard_build_and_deploy:
name: Build and deploy dashboard via dashboard pipeline step function
needs: [redeploy_gp2gp_infrastructure_step_functions]
environment: dev
runs-on: ubuntu-latest
steps:
- name: Configure AWS credentials
id: credentials
uses: aws-actions/configure-aws-credentials@v6
with:
mask-aws-account-id: true
role-to-assume: ${{ secrets.AWS_ASSUME_ROLE }}
role-skip-session-tagging: true
aws-region: ${{ vars.AWS_REGION }}
- name: Get current date
id: date
run: echo "date=$(date +'%Y-%m-%d')" >> $GITHUB_OUTPUT
- name: Run step function
run: |
aws stepfunctions start-execution \
--state-machine-arn "arn:aws:states:eu-west-2:${{ steps.credentials.outputs.aws-account-id }}:stateMachine:dashboard-pipeline" \
--input '{"SKIP_METRICS": true,"time": "${{ steps.date.outputs.date }}"}'