generated from ministryofjustice/template-repository
-
Notifications
You must be signed in to change notification settings - Fork 0
161 lines (154 loc) · 6.51 KB
/
service-catalogue.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
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
name: Service catalogue
# Add projects to the HMPPS Service Catalogue
on:
workflow_dispatch:
inputs:
projects:
description: Project
type: choice
required: true
options:
- 'All'
- '["accredited-programmes-and-oasys"]'
- '["approved-premises-and-delius"]'
- '["approved-premises-and-oasys"]'
- '["arns-and-delius"]'
- '["assessment-summary-and-delius"]'
- '["cas2-and-delius"]'
- '["cas3-and-delius"]'
- '["core-person-record-and-delius"]'
- '["court-case-and-delius"]'
- '["create-and-vary-a-licence-and-delius"]'
- '["custody-key-dates-and-delius"]'
- '["domain-events-and-delius"]'
- '["dps-and-delius"]'
- '["effective-proposal-framework-and-delius"]'
- '["external-api-and-delius"]'
- '["hdc-licences-and-delius"]'
- '["hmpps-auth-and-delius"]'
- '["make-recall-decisions-and-delius"]'
- '["manage-offences-and-delius"]'
- '["manage-pom-cases-and-delius"]'
- '["manage-supervision-and-delius"]'
- '["manage-supervision-and-oasys"]'
- '["oasys-and-delius"]'
- '["offender-events-and-delius"]'
- '["opd-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"]'
- '["prison-education-and-delius"]'
- '["prison-identifier-and-delius"]'
- '["prisoner-profile-and-delius"]'
- '["probation-search-and-delius"]'
- '["refer-and-monitor-and-delius"]'
- '["resettlement-passport-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"]'
- '["subject-access-requests-and-delius"]'
- '["common-platform-and-delius"]'
- '["ims-and-delius"]'
- '["appointment-reminders-and-delius"]'
- '["justice-email-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
push:
branches:
- main
paths:
- 'projects/**/deploy/**'
jobs:
get-projects:
outputs:
projects: ${{ steps.output.outputs.projects }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- id: check-changes
if: github.event_name == 'push'
uses: ./.github/actions/check-changes
with:
filters: |
projects:
- 'projects/**/deploy/**'
- name: Get projects - changed
if: github.event_name == 'push'
run: echo "projects=$PROJECTS" | tee -a "$GITHUB_ENV"
env:
PROJECTS: ${{ steps.check-changes.outputs.projects }}
- name: Get projects - all
if: github.event_name == 'workflow_dispatch' && inputs.projects == 'All'
run: echo "projects=$(find projects -mindepth 1 -maxdepth 1 -printf "%f\n" | jq --raw-input . | jq --slurp --compact-output .)" | tee -a "$GITHUB_ENV"
- name: Get projects - selected
if: github.event_name == 'workflow_dispatch' && inputs.projects != 'All'
run: echo 'projects=${{ inputs.projects }}' | tee -a "$GITHUB_ENV"
- id: output
run: echo 'projects=${{ env.projects }}' | tee -a "$GITHUB_OUTPUT"
update-catalogue:
runs-on: ubuntu-latest
needs: get-projects
strategy:
fail-fast: false
matrix:
project: ${{ fromJson(needs.get-projects.outputs.projects) }}
steps:
- uses: actions/checkout@v4
- uses: ./.github/actions/cloud-platform-auth
with:
api: ${{ secrets.KUBE_ENV_API }}
cert: ${{ secrets.KUBE_CERT }}
cluster: ${{ secrets.KUBE_CLUSTER }}
namespace: ${{ secrets.KUBE_NAMESPACE }}
token: ${{ secrets.KUBE_TOKEN }}
- name: Get environment details
id: environments
run: |
environments=[]
for env in dev preprod prod; do
values_file="projects/$PROJECT_NAME/deploy/values-$env.yml"
if [ -f "$values_file" ] && [ "$(yq '.enabled' "$values_file" | sed 's/^null$/true/')" = "true" ] && [ -n "$(yq '.generic-service.ingress.host' "$values_file")" ]; then
url=$(yq '.generic-service.ingress.host' "$values_file")
health_path=$(yq '.generic-service.livenessProbe.httpGet.path // "/health"' "projects/$PROJECT_NAME/deploy/values.yaml")
environments=$(echo "$environments" | jq -c '. += [{
"name": $name,
"type": $name,
"url": ("https://" + $url),
"health_path": $health_path,
"info_path": "/info",
"namespace": ("hmpps-probation-integration-services-" + $name)
}]' --arg name "$env" --arg url "$url" --arg health_path "$health_path")
fi
done
echo "environments=$environments" | tee -a "$GITHUB_OUTPUT"
env:
PROJECT_NAME: ${{ matrix.project }}
- name: Update catalogue
run: |
./script/start-service-pod.sh
PROJECT_TITLE="$(awk 'BEGIN {RS=""; FS="\n"} !/^[#\/]/ {gsub("\n", " ", $0); sub(/\. .*/, "."); print; exit}' "projects/$PROJECT_NAME/README.md")" # First line of the project's README.md
kubectl cp ./script/update-service-catalogue.sh "$POD_NAME:/tmp/update-service-catalogue.sh"
kubectl exec "$POD_NAME" -- env \
PROJECT_NAME="$PROJECT_NAME" \
PROJECT_TITLE="$PROJECT_TITLE" \
ENVIRONMENTS="$ENVIRONMENTS" \
SERVICE_CATALOGUE_API_KEY="$SERVICE_CATALOGUE_API_KEY" \
/tmp/update-service-catalogue.sh
env:
NAMESPACE: ${{ secrets.KUBE_NAMESPACE }}
POD_NAME: sc-${{ matrix.project }}
PROJECT_NAME: ${{ matrix.project }}
ENVIRONMENTS: ${{ steps.environments.outputs.environments }}
SERVICE_CATALOGUE_API_KEY: ${{ secrets.SERVICE_CATALOGUE_API_KEY }}
- name: Delete pod
if: always()
run: kubectl delete pod "$POD_NAME" || true
env:
POD_NAME: sc-${{ matrix.project }}