44
55# Usage:
66# ./dispatch_internal_repo_workflow.sh \
7- # --jobName <name> \
87# --infraRepoName <repo> \
98# --releaseVersion <version> \
109# --targetWorkflow <workflow.yaml> \
1413# --terraformAction <action> \
1514# --internalRef <ref>
1615#
17- # All arguments are required except jobName, terraformAction, and internalRef.
16+ # All arguments are required except terraformAction, and internalRef.
1817# Example:
1918# ./dispatch_internal_repo_workflow.sh \
20- # --jobName "Deploy" \
2119# --infraRepoName "nhs-notify-web-template-management" \
2220# --releaseVersion "v1.2.3" \
2321# --targetWorkflow "deploy.yaml" \
@@ -31,10 +29,6 @@ set -e
3129
3230while [[ $# -gt 0 ]]; do
3331 case $1 in
34- --jobName) # Name of the job triggering the remote workflow (optional)
35- jobName=" $2 "
36- shift 2
37- ;;
3832 --infraRepoName) # Name of the infrastructure repo in NHSDigital org (required)
3933 infraRepoName=" $2 "
4034 shift 2
@@ -84,10 +78,6 @@ if [[ -z "$PR_TRIGGER_PAT" ]]; then
8478 exit 1
8579fi
8680
87- if [[ -z " $jobName " ]]; then
88- jobName=" ${infraRepoName} -${targetComponent} -${terraformAction} "
89- fi
90-
9181if [[ -z " $overrides " ]]; then
9282 overrides=" "
9383fi
@@ -97,7 +87,6 @@ if [[ -z "$internalRef" ]]; then
9787fi
9888
9989echo " ==================== Workflow Dispatch Parameters ===================="
100- echo " jobName: $jobName "
10190echo " infraRepoName: $infraRepoName "
10291echo " releaseVersion: $releaseVersion "
10392echo " targetWorkflow: $targetWorkflow "
@@ -108,16 +97,13 @@ echo " terraformAction: $terraformAction"
10897echo " internalRef: $internalRef "
10998echo " overrides: $overrides "
11099
111- callerRunId=" ${GITHUB_RUN_ID} -${jobName} -${GITHUB_RUN_ATTEMPT} "
112-
113100DISPATCH_EVENT=$( jq -ncM \
114101 --arg infraRepoName " $infraRepoName " \
115102 --arg releaseVersion " $releaseVersion " \
116103 --arg targetEnvironment " $targetEnvironment " \
117104 --arg targetAccountGroup " $targetAccountGroup " \
118105 --arg targetComponent " $targetComponent " \
119106 --arg terraformAction " $terraformAction " \
120- --arg callerRunId " $callerRunId " \
121107 --arg targetWorkflow " $targetWorkflow " \
122108 --arg overrides " $overrides " \
123109 ' {
@@ -131,9 +117,7 @@ DISPATCH_EVENT=$(jq -ncM \
131117 "targetAccountGroup": $targetAccountGroup,
132118 "targetComponent": $targetComponent,
133119 "overrides": $overrides,
134- } +
135- (if ($targetWorkflow | test("dispatch-(acceptance|contextual|product|security)-tests-.*\\.yaml"))
136- then { "callerRunId": $callerRunId } else {} end)
120+ }
137121 )
138122 }' )
139123
@@ -175,7 +159,6 @@ for _ in {1..18}; do
175159 fi
176160
177161 workflow_run_url=$( echo " $response " | jq -r \
178- --arg callerRunId " $callerRunId " \
179162 --arg targetWorkflow " $targetWorkflow " \
180163 --arg targetEnvironment " $targetEnvironment " \
181164 --arg targetAccountGroup " $targetAccountGroup " \
@@ -189,10 +172,6 @@ for _ in {1..18}; do
189172 and contains($targetComponent)
190173 and contains($terraformAction)
191174 )
192- | if ($targetWorkflow | test("dispatch-(acceptance|contextual|product|security)-tests-.*\\.yaml"))
193- then select(.name | contains("caller:" + $callerRunId))
194- else .
195- end
196175 | .url' )
197176
198177 if [[ -n " $workflow_run_url " && " $workflow_run_url " != null ]]; then
0 commit comments