@@ -58,14 +58,16 @@ jobs:
5858 - name : Trigger nhs-notify-internal workflow
5959 shell : bash
6060 run : |
61+ callerRunId="${GITHUB_RUN_ID}-${{ inputs.jobName }}-${GITHUB_RUN_ATTEMPT}"
62+
6163 DISPATCH_EVENT=$(jq -ncM \
6264 --arg infraRepoName "${{ inputs.infraRepoName }}" \
63- --arg releaseVersion ${{ inputs.releaseVersion }} \
64- --arg targetEnvironment ${{ inputs.targetEnvironment }} \
65- --arg targetAccountGroup ${{ inputs.targetAccountGroup }} \
66- --arg targetComponent ${{ inputs.targetComponent }} \
65+ --arg releaseVersion " ${{ inputs.releaseVersion }}" \
66+ --arg targetEnvironment " ${{ inputs.targetEnvironment }}" \
67+ --arg targetAccountGroup " ${{ inputs.targetAccountGroup }}" \
68+ --arg targetComponent " ${{ inputs.targetComponent }}" \
6769 --arg terraformAction "${{ inputs.terraformAction }}" \
68- --arg callerRunId "${GITHUB_RUN_ID}-${{ inputs.jobName }}-${GITHUB_RUN_ATTEMPT}" \
70+ --arg callerRunId "$callerRunId" \
6971 --arg targetWorkflow "${{ inputs.targetWorkflow }}" \
7072 '{
7173 "ref": "${{ inputs.internalRef }}",
7880 "targetAccountGroup": $targetAccountGroup,
7981 "targetComponent": $targetComponent
8082 } +
81- (if ($targetWorkflow | test("dispatch-(acceptance|contextual|product|security)-tests-.*.yaml"))
83+ (if ($targetWorkflow | test("dispatch-(acceptance|contextual|product|security)-tests-.*\\ .yaml"))
8284 then { "callerRunId": $callerRunId } else {} end)
8385 )
8486 }')
9799 echo "Workflow triggered. Waiting for the workflow to complete.."
98100
99101 # Poll GitHub API to check the workflow status
100- callerRunId="${GITHUB_RUN_ID}-${{ inputs.jobName }}-${GITHUB_RUN_ATTEMPT}"
101102
102103 workflow_run_url=""
103104 for i in {1..18}; do
@@ -106,16 +107,22 @@ jobs:
106107 -H "Authorization: Bearer ${{ secrets.PR_TRIGGER_PAT }}" \
107108 -H "X-GitHub-Api-Version: 2022-11-28" \
108109 "https://api.github.com/repos/NHSDigital/nhs-notify-internal/actions/runs?event=workflow_dispatch" \
109- | jq -r --arg callerRunId "$callerRunId" \
110- --arg targetWorkflow "${{ inputs.targetWorkflow }}" \
110+ | jq -r \
111+ --arg callerRunId "$callerRunId" \
112+ --arg targetWorkflow "${{ inputs.targetWorkflow }}" \
113+ --arg targetEnvironment "${{ inputs.targetEnvironment }}" \
114+ --arg targetAccountGroup "${{ inputs.targetAccountGroup }}" \
115+ --arg targetComponent "${{ inputs.targetComponent }}" \
116+ --arg terraformAction "${{ inputs.terraformAction }}" \
111117 '.workflow_runs[]
112118 | select(.path == ".github/workflows/" + $targetWorkflow)
113119 | select(.name
114- | contains("'${{ inputs.targetEnvironment }}'") and
115- contains("'${{ inputs.targetAccountGroup }}'") and
116- contains("'${{ inputs.targetComponent }}'") and
117- contains("'${{ inputs.terraformAction }}'"))
118- | if ($targetWorkflow | test("dispatch-(acceptance|contextual|product|security)-tests-.*.yaml"))
120+ | contains($targetEnvironment)
121+ and contains($targetAccountGroup)
122+ and contains($targetComponent)
123+ and contains($terraformAction)
124+ )
125+ | if ($targetWorkflow | test("dispatch-(acceptance|contextual|product|security)-tests-.*\\.yaml"))
119126 then select(.name | contains("caller:" + $callerRunId))
120127 else .
121128 end
0 commit comments