forked from nhsx/standards-registry
-
Notifications
You must be signed in to change notification settings - Fork 0
94 lines (88 loc) · 3.32 KB
/
helm-deploy-ui.yml
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
on:
workflow_call:
inputs:
environment:
description: 'Which environment to deploy to [dev|test|prod]'
required: true
type: string
pages_ckan_url:
default: 'https://manage.standards.nhs.uk/api/action'
description: 'The url used to read static page information from'
required: false
type: string
ecr_repository:
default: nhsx-standards-directory
description: 'The ECR registry to use for the built image'
required: false
type: string
secrets:
ckan_url:
description: 'The ckan url to use, e.g. https://manage.dev.standards.nhs.uk/api/action'
required: true
tracking_id:
required: true
google_tag_id:
required: true
ecr_registry:
required: true
kubeconfig_file:
required: true
aws_access_key_id:
required: true
aws_secret_access_key:
required: true
google_site_code:
required: true
jobs:
container-and-helm:
runs-on: ubuntu-latest
environment: ${{ inputs.environment }}
defaults:
run:
working-directory: ui
env:
AWS_REGION: eu-west-2
IMAGE_TAG: ui-${{ github.sha }}
steps:
- name: checkout
uses: actions/checkout@v3
- name: configure credentials (using us-east-1)
uses: aws-actions/configure-aws-credentials@v1-node16
with:
aws-access-key-id: ${{ secrets.aws_access_key_id }}
aws-secret-access-key: ${{ secrets.aws_secret_access_key }}
aws-region: us-east-1
- name: Login to Public ECR
uses: docker/login-action@v2
with:
registry: public.ecr.aws
username: ${{ secrets.aws_access_key_id }}
password: ${{ secrets.aws_secret_access_key }}
env:
AWS_REGION: ${{ env.AWS_REGION }}
- name: build and push
id: build-image
run: |
# Build a docker container and push it to ECR
docker build \
--build-arg NEXT_PUBLIC_ENV=${{ inputs.environment }} \
--build-arg NEXT_PUBLIC_TAG_ID=${{ secrets.google_tag_id }} \
--build-arg NEXT_PUBLIC_TRACKING_ID=${{ secrets.tracking_id }} \
--build-arg NEXT_PUBLIC_SITE_CODE=${{ secrets.google_site_code }} \
-t ${{ inputs.ecr_repository }}:$IMAGE_TAG .
docker tag ${{ inputs.ecr_repository }}:$IMAGE_TAG ${{ secrets.ecr_registry }}/${{ inputs.ecr_repository }}:$IMAGE_TAG
docker push ${{ secrets.ecr_registry }}/${{ inputs.ecr_repository }}:$IMAGE_TAG
- name: update helm
uses: koslib/[email protected]
env:
KUBE_CONFIG_DATA: ${{ secrets.kubeconfig_file }}
with:
command: >-
helm upgrade --debug --install --wait -n ${{inputs.environment}} ui ./charts/ui
--set ui.config.ckanurl='${{ secrets.ckan_url }}'
--set ui.config.tracking_id='${{ secrets.tracking_id }}'
--set ui.config.google_tag_id='${{ secrets.google_tag_id }}'
--set ui.container.image=${{ secrets.ecr_registry }}/${{ inputs.ecr_repository }}:$IMAGE_TAG
--set ui.config.pagesckanurl=${{ inputs.pages_ckan_url }}
--set ui.config.environment=${{ inputs.environment }}
--set ui.config.google_site_code=${{ inputs.google_site_code }}