generated from ministryofjustice/template-repository
-
Notifications
You must be signed in to change notification settings - Fork 0
143 lines (134 loc) · 5.22 KB
/
deploy.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
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
134
135
136
137
138
139
140
141
142
143
name: Deploy
on:
workflow_call:
inputs:
projects:
description: A JSON array of projects to deploy
type: string
required: true
environment:
description: The name of the environment to deploy to
type: string
required: true
version:
description: The image version to deploy
type: string
required: true
workflow_dispatch:
inputs:
projects:
description: Project
type: choice
required: true
options:
- '["approved-premises-and-delius"]'
- '["approved-premises-and-oasys"]'
- '["court-case-and-delius"]'
- '["create-and-vary-a-licence-and-delius"]'
- '["custody-key-dates-and-delius"]'
- '["domain-events-and-delius"]'
- '["effective-proposal-framework-and-delius"]'
- '["external-api-and-delius"]'
- '["make-recall-decisions-and-delius"]'
- '["manage-pom-cases-and-delius"]'
- '["offender-events-and-delius"]'
- '["pathfinder-and-delius"]'
- '["person-search-index-from-delius"]'
- '["pre-sentence-reports-to-delius"]'
- '["prison-case-notes-to-probation"]'
- '["prison-custody-status-to-delius"]'
- '["refer-and-monitor-and-delius"]'
- '["risk-assessment-scores-to-delius"]'
- '["sentence-plan-and-delius"]'
- '["sentence-plan-and-oasys"]'
- '["soc-and-delius"]'
- '["tier-to-delius"]'
- '["unpaid-work-and-delius"]'
- '["workforce-allocations-to-delius"]'
- '["manage-offences-and-delius"]'
- '["resettlement-passport-and-delius"]'
- '["prison-education-and-delius"]'
- '["opd-and-delius"]'
- '["hmpps-auth-and-delius"]'
- '["dps-and-delius"]'
- '["arns-and-delius"]'
- '["cas3-and-delius"]'
# ^ add new projects here
# GitHub Actions doesn't support dynamic choices, we must add each project here to enable manual deployments
# See https://github.com/community/community/discussions/11795
environment:
description: Environment
type: choice
required: true
options:
- test
- preprod
- prod
version:
description: Image version
type: string
required: true
jobs:
deploy:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
project: ${{ fromJson(inputs.projects) }}
concurrency: deploy-${{ matrix.project }}-${{ inputs.environment }}
environment:
name: ${{ inputs.environment }}
steps:
- uses: actions/checkout@v4
- uses: ./.github/actions/get-env-details
id: env
with:
environment: ${{ inputs.environment }}
- name: Get enabled flag from values file
id: enabled
shell: bash
run: echo "enabled=$(yq '.enabled' "$VALUES_FILE" | sed 's/^null$/true/')" | tee -a "$GITHUB_OUTPUT"
working-directory: projects/${{ matrix.project }}/deploy
env:
VALUES_FILE: ${{ steps.env.outputs.values-file }}
- name: Check Chart.yaml file exists
id: check_files
uses: andstor/file-existence-action@20b4d2e596410855db8f9ca21e96fbe18e12930b # v2
with:
files: projects/${{ matrix.project }}/deploy/Chart.yaml
- name: Deploy to Cloud Platform
if: ${{ steps.check_files.outputs.files_exists == 'true' && steps.enabled.outputs.enabled == 'true' }}
uses: ./.github/actions/cloud-platform-deploy
with:
project: ${{ matrix.project }}
environment: ${{ inputs.environment }}
version: ${{ inputs.version }}
api: ${{ secrets.KUBE_ENV_API }}
cert: ${{ secrets.KUBE_CERT }}
cluster: ${{ secrets.KUBE_CLUSTER }}
namespace: ${{ secrets.KUBE_NAMESPACE }}
token: ${{ secrets.KUBE_TOKEN }}
- uses: docker/login-action@v3
if: ${{ steps.check_files.outputs.files_exists == 'true' && steps.enabled.outputs.enabled == 'true' }}
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ github.token }}
- name: Tag image with environment
if: ${{ steps.check_files.outputs.files_exists == 'true' && steps.enabled.outputs.enabled == 'true' }}
run: |
docker pull "$image:${{ inputs.version }}"
docker pull "$image:${{ inputs.environment }}" && docker image tag "$image:${{ inputs.environment }}" "$image:${{ inputs.environment }}-prev"
docker image tag "$image:${{ inputs.version }}" "$image:${{ inputs.environment }}"
docker push --all-tags "$image"
env:
image: ghcr.io/ministryofjustice/hmpps-probation-integration-services/${{ matrix.project }}
- name: Create Sentry release
if: ${{ steps.check_files.outputs.files_exists == 'true' && steps.enabled.outputs.enabled == 'true' }}
uses: getsentry/action-release@v1
env:
SENTRY_ORG: ministryofjustice
SENTRY_PROJECT: ${{ matrix.project }}
SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }}
with:
environment: ${{ inputs.environment }}