Skip to content

Commit 7b64c13

Browse files
authored
Merge pull request #166 from hmcts/AMP-313/auto-deploy-pipeline
feat: add automated deployment pipeline via ADO
2 parents 0abe9bf + 8c9c18e commit 7b64c13

File tree

3 files changed

+76
-4
lines changed

3 files changed

+76
-4
lines changed

.github/workflows/ci-build-publish.yml

Lines changed: 62 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,12 @@ on:
99
required: true
1010
HMCTS_ADO_PAT:
1111
required: true
12+
DEPLOYMENT_APP_ID:
13+
required: true
14+
description: "GitHub App ID for deployment"
15+
DEPLOYMENT_APP_PRIVATE_KEY:
16+
required: true
17+
description: "GitHub App private key for deployment"
1218
inputs:
1319
environment:
1420
required: true
@@ -27,6 +33,10 @@ on:
2733
trigger_deploy:
2834
required: true
2935
type: boolean
36+
deploy_environment:
37+
required: false
38+
type: string
39+
default: dev
3040

3141
jobs:
3242
Artefact-Version:
@@ -160,12 +170,15 @@ jobs:
160170
needs: [ Build, Artefact-Version ]
161171
if: ${{ inputs.trigger_deploy }}
162172
runs-on: ubuntu-latest
173+
outputs:
174+
run_id: ${{ steps.trigger.outputs.run_id }}
163175
steps:
164176
- name: Extract repo name
165177
run: echo "REPO_NAME=${GITHUB_REPOSITORY##*/}" >> $GITHUB_ENV
166178

167-
- name: Trigger ADO pipeline
168-
uses: hmcts/trigger-ado-pipeline@v1
179+
- name: Trigger ADO pipeline 460
180+
id: trigger
181+
uses: hmcts/trigger-ado-pipeline@v2
169182
with:
170183
pipeline_id: 460
171184
ado_pat: ${{ secrets.HMCTS_ADO_PAT }}
@@ -178,3 +191,50 @@ jobs:
178191
"agentDemand": "ubuntu-j25",
179192
"baseImage": "hmcts/apm-services:25-jre"
180193
}
194+
195+
Wait-For-ACR-Push:
196+
needs: [Deploy]
197+
if: ${{ inputs.trigger_deploy }}
198+
runs-on: ubuntu-latest
199+
steps:
200+
- name: Wait for ADO pipeline 460
201+
uses: hmcts/monitor-ado-pipeline@v1
202+
with:
203+
pipeline_id: 460
204+
run_id: ${{ needs.Deploy.outputs.run_id }}
205+
ado_pat: ${{ secrets.HMCTS_ADO_PAT }}
206+
poll_interval: 30
207+
timeout: 1800
208+
209+
deploy-dev:
210+
needs: [Wait-For-ACR-Push, Artefact-Version, Build]
211+
if: ${{ inputs.trigger_deploy }}
212+
runs-on: ubuntu-latest
213+
steps:
214+
- name: Generate date suffix
215+
id: date
216+
shell: bash
217+
run: echo "suffix=_$(date -u +'%d%m%y')" >> "$GITHUB_OUTPUT"
218+
219+
- name: Deploy via ADO pipeline
220+
uses: hmcts/action-ado-deploy@v1
221+
with:
222+
service_name: ${{ needs.Build.outputs.repo_name }}
223+
image_tag: ${{ needs.Artefact-Version.outputs.artefact_version }}
224+
tag_suffix: ${{ steps.date.outputs.suffix }}
225+
app_id: ${{ secrets.DEPLOYMENT_APP_ID }}
226+
app_private_key: ${{ secrets.DEPLOYMENT_APP_PRIVATE_KEY }}
227+
target_repository: hmcts/cp-vp-aks-deploy
228+
target_branch: env/dev
229+
values_file: vp-config/services_values.yml
230+
pipeline_id: 434
231+
ado_pat: ${{ secrets.HMCTS_ADO_PAT }}
232+
ref_name: refs/heads/env/dev
233+
wait: false
234+
template_parameters: >
235+
{
236+
"env": "dev",
237+
"cpbackendenv": "steccm64",
238+
"stack": "devamp01",
239+
"cluster": "K8-DEV-CS01-CL02"
240+
}

.github/workflows/ci-draft.yml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,16 @@ on:
1313
jobs:
1414
ci-draft:
1515
uses: ./.github/workflows/ci-build-publish.yml
16-
secrets: inherit
16+
secrets:
17+
AZURE_DEVOPS_ARTIFACT_USERNAME: ${{ secrets.AZURE_DEVOPS_ARTIFACT_USERNAME }}
18+
AZURE_DEVOPS_ARTIFACT_TOKEN: ${{ secrets.AZURE_DEVOPS_ARTIFACT_TOKEN }}
19+
HMCTS_ADO_PAT: ${{ secrets.HMCTS_CP_ADO_PAT }}
20+
DEPLOYMENT_APP_ID: ${{ secrets.DEPLOYMENT_APP_ID }}
21+
DEPLOYMENT_APP_PRIVATE_KEY: ${{ secrets.DEPLOYMENT_APP_PRIVATE_KEY }}
1722
with:
1823
environment: dev
1924
is_publish: ${{ github.event_name == 'push' }}
2025
trigger_docker: ${{ github.event_name == 'push' }}
2126
trigger_deploy: ${{ github.event_name == 'push' }}
27+
deploy_environment: dev
2228

.github/workflows/ci-released.yml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,16 @@ on:
88
jobs:
99
ci-release:
1010
uses: ./.github/workflows/ci-build-publish.yml
11-
secrets: inherit
11+
secrets:
12+
AZURE_DEVOPS_ARTIFACT_USERNAME: ${{ secrets.AZURE_DEVOPS_ARTIFACT_USERNAME }}
13+
AZURE_DEVOPS_ARTIFACT_TOKEN: ${{ secrets.AZURE_DEVOPS_ARTIFACT_TOKEN }}
14+
HMCTS_ADO_PAT: ${{ secrets.HMCTS_CP_ADO_PAT }}
15+
DEPLOYMENT_APP_ID: ${{ secrets.DEPLOYMENT_APP_ID }}
16+
DEPLOYMENT_APP_PRIVATE_KEY: ${{ secrets.DEPLOYMENT_APP_PRIVATE_KEY }}
1217
with:
1318
environment: dev
1419
is_release: true
1520
is_publish: true
1621
trigger_docker: true
1722
trigger_deploy: true
23+
deploy_environment: dev

0 commit comments

Comments
 (0)