Skip to content

Commit 4e21e4c

Browse files
authored
feat: DToSS-9902 end to end pipeline GitHub action (#1490)
Initial GitHub workflow to test
1 parent b4f35f0 commit 4e21e4c

File tree

2 files changed

+126
-0
lines changed

2 files changed

+126
-0
lines changed
Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
name: Deployment stage
2+
3+
on:
4+
workflow_call:
5+
inputs:
6+
environments:
7+
description: List of environments to deploy to (String array)
8+
required: true
9+
type: string
10+
commit_sha:
11+
description: Commit SHA used to fetch ADO pipeline and docker image
12+
required: true
13+
type: string
14+
pr_number:
15+
description: Pull request number when used in a pull request
16+
required: false
17+
type: string
18+
19+
workflow_dispatch:
20+
inputs:
21+
environments:
22+
description: List of environments to deploy to (String array)
23+
required: true
24+
type: string
25+
commit_sha:
26+
description: Commit SHA used to fetch ADO pipeline and docker image
27+
required: true
28+
type: string
29+
pr_number:
30+
description: Pull request number when used in a pull request
31+
required: false
32+
type: string
33+
34+
jobs:
35+
deploy:
36+
name: Deploy
37+
runs-on: ubuntu-latest
38+
strategy:
39+
matrix:
40+
environment: ${{ fromJson(inputs.environments) }}
41+
max-parallel: 1
42+
environment: ${{ matrix.environment }}
43+
concurrency: deploy-${{ matrix.environment }}-${{ github.ref }}
44+
45+
steps:
46+
- name: Checkout code
47+
uses: actions/checkout@v5
48+
49+
- uses: azure/login@bbcc074a232a35d7283353c18aabf0de1d557775
50+
with:
51+
client-id: ${{ secrets.AZURE_CLIENT_ID }}
52+
tenant-id: ${{ secrets.AZURE_TENANT_ID }}
53+
subscription-id: ${{ secrets.AZURE_SUBSCRIPTION_ID }}
54+
55+
- name: Call deployment pipeline
56+
run: |
57+
# Define common variables
58+
organisation='https://dev.azure.com/nhse-dtos/'
59+
project_name='dtos-cohort-manager'
60+
61+
# Define which tests to run based on the environment
62+
declare -A test_types=(
63+
["dev"]="smoke_e2e,regression_api,regression_e2e_epic1,regression_e2e_epic2,regression_e2e_epic3"
64+
["nft"]="smoke_e2e,regression_api,regression_e2e_epic1,regression_e2e_epic2,regression_e2e_epic3"
65+
["int"]=""
66+
["sandbox"]="smoke_e2e,regression_api"
67+
["pre"]=""
68+
["prod"]=""
69+
)
70+
71+
parameters='dockerImageTag=${{inputs.commit_sha}} retagImages=false testTypes=[${test_types[matrix.environment]}]'
72+
73+
echo "Starting Azure devops pipeline \"Deploy to Azure - Core ${{ matrix.environment }}\"..."
74+
# RUN_ID=$(az pipelines run \
75+
# --commit-id ${{inputs.commit_sha}} \
76+
# --name "Deploy to Azure - Core ${{ matrix.environment }}" \
77+
# --org "${organisation}" \
78+
# --project "${project_name}" \
79+
# --parameters $parameters \
80+
# --output tsv --query id)
81+
82+
# scripts/bash/wait_ado_pipeline.sh "$RUN_ID" https://dev.azure.com/nhse-dtos "${project_name}"

scripts/bash/wait_ado_pipeline.sh

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
#!/bin/bash
2+
3+
set -euo pipefail
4+
5+
RUN_ID="$1"
6+
ORG_URL="$2"
7+
PROJECT="$3"
8+
9+
SLEEP_TIME=15
10+
TIMEOUT_SECONDS=300
11+
12+
echo "Waiting for Azure DevOps pipeline run $RUN_ID to complete..."
13+
14+
START_TIME=$(date +%s)
15+
16+
while true; do
17+
PIPELINE_JSON=$(az pipelines runs show \
18+
--id "$RUN_ID" \
19+
--org "$ORG_URL" \
20+
--project "$PROJECT" \
21+
--output json)
22+
STATUS=$(echo "$PIPELINE_JSON" | jq -r '.status')
23+
RESULT=$(echo "$PIPELINE_JSON" | jq -r '.result')
24+
25+
if [[ "$STATUS" == "completed" ]]; then
26+
if [[ "$RESULT" == "succeeded" ]]; then
27+
echo "Status: $STATUS. Pipeline run $RUN_ID succeeded."
28+
exit 0
29+
else
30+
echo "Status: $STATUS. Pipeline run $RUN_ID failed with result: $RESULT"
31+
exit 1
32+
fi
33+
fi
34+
35+
CURRENT_TIME=$(date +%s)
36+
ELAPSED=$((CURRENT_TIME - START_TIME))
37+
if (( ELAPSED > TIMEOUT_SECONDS )); then
38+
echo "ERROR: Timeout of ${TIMEOUT_SECONDS}s reached while waiting for pipeline run $RUN_ID."
39+
exit 2
40+
fi
41+
42+
echo "Status: $STATUS (Elapsed: ${ELAPSED}s)"
43+
sleep "$SLEEP_TIME"
44+
done

0 commit comments

Comments
 (0)