@@ -83,72 +83,72 @@ jobs:
8383 }')
8484
8585 # Trigger The workflow
86- curl -L \
87- --fail \
88- --silent \
89- -X POST \
90- -H "Accept: application/vnd.github+json" \
91- -H "Authorization: Bearer ${{ secrets.PR_TRIGGER_PAT }}" \
92- -H "X-GitHub-Api-Version: 2022-11-28" \
93- "https://api.github.com/repos/NHSDigital/nhs-notify-internal/actions/workflows/${{ inputs.targetWorkflow }}/dispatches" \
94- -d "${DISPATCH_EVENT}"
95-
96- echo "Workflow triggered. Waiting for the workflow to complete.."
97-
98- # Poll GitHub API to check the workflow status
99- workflow_run_url=""
100- for i in {1..12}; do
101- workflow_run_url=$(curl -s \
102- -H "Accept: application/vnd.github+json" \
103- -H "Authorization: Bearer ${{ secrets.PR_TRIGGER_PAT }}" \
104- -H "X-GitHub-Api-Version: 2022-11-28" \
105- "https://api.github.com/repos/NHSDigital/nhs-notify-internal/actions/runs?event=workflow_dispatch&status=in_progress" \
106- | jq -r '.workflow_runs[]
107- | select(.name
108- | contains("'${{ inputs.targetEnvironment }}'") and
109- contains("'${{ inputs.targetAccountGroup }}'") and
110- contains("'${{ inputs.targetComponent }}'") and
111- contains("'${{ inputs.terraformAction }}'"))
112- | .url')
113-
114- if [[ -n "$workflow_run_url" && "$workflow_run_url" != null ]]; then
115- ui_url=${workflow_run_url/api./}
116- ui_url=${ui_url/\/repos/}
117- echo "Found workflow run url: $ui_url"
118- echo "workflow_run_url=$workflow_run_url" >> $GITHUB_ENV
119- break
120- fi
121-
122- echo "Waiting for workflow to start..."
123- sleep 10
124- done
125-
126- if [[ -z "$workflow_run_url" || "$workflow_run_url" == null ]]; then
127- echo "Failed to get the workflow run url. Exiting."
128- exit 1
129- fi
130-
131- # Wait for workflow completion
132- while true; do
133- sleep 10
134- response=$(curl -s -L \
135- -H "Authorization: Bearer ${{ secrets.PR_TRIGGER_PAT }}" \
136- -H "Accept: application/vnd.github+json" \
137- $workflow_run_url)
138-
139- status=$(echo "$response" | jq -r '.status')
140- conclusion=$(echo "$response" | jq -r '.conclusion')
141-
142- if [ "$status" == "completed" ]; then
143- if [ "$conclusion" == "success" ]; then
144- echo "Workflow completed successfully."
145- exit 0
146- else
147- echo "Workflow failed with conclusion: $conclusion"
148- exit 1
149- fi
150- fi
151-
152- echo "Workflow still running..."
153- sleep 20
154- done
86+ # curl -L \
87+ # --fail \
88+ # --silent \
89+ # -X POST \
90+ # -H "Accept: application/vnd.github+json" \
91+ # -H "Authorization: Bearer ${{ secrets.PR_TRIGGER_PAT }}" \
92+ # -H "X-GitHub-Api-Version: 2022-11-28" \
93+ # "https://api.github.com/repos/NHSDigital/nhs-notify-internal/actions/workflows/${{ inputs.targetWorkflow }}/dispatches" \
94+ # -d "${DISPATCH_EVENT}"
95+
96+ # echo "Workflow triggered. Waiting for the workflow to complete.."
97+
98+ # # Poll GitHub API to check the workflow status
99+ # workflow_run_url=""
100+ # for i in {1..12}; do
101+ # workflow_run_url=$(curl -s \
102+ # -H "Accept: application/vnd.github+json" \
103+ # -H "Authorization: Bearer ${{ secrets.PR_TRIGGER_PAT }}" \
104+ # -H "X-GitHub-Api-Version: 2022-11-28" \
105+ # "https://api.github.com/repos/NHSDigital/nhs-notify-internal/actions/runs?event=workflow_dispatch&status=in_progress" \
106+ # | jq -r '.workflow_runs[]
107+ # | select(.name
108+ # | contains("'${{ inputs.targetEnvironment }}'") and
109+ # contains("'${{ inputs.targetAccountGroup }}'") and
110+ # contains("'${{ inputs.targetComponent }}'") and
111+ # contains("'${{ inputs.terraformAction }}'"))
112+ # | .url')
113+
114+ # if [[ -n "$workflow_run_url" && "$workflow_run_url" != null ]]; then
115+ # ui_url=${workflow_run_url/api./}
116+ # ui_url=${ui_url/\/repos/}
117+ # echo "Found workflow run url: $ui_url"
118+ # echo "workflow_run_url=$workflow_run_url" >> $GITHUB_ENV
119+ # break
120+ # fi
121+
122+ # echo "Waiting for workflow to start..."
123+ # sleep 10
124+ # done
125+
126+ # if [[ -z "$workflow_run_url" || "$workflow_run_url" == null ]]; then
127+ # echo "Failed to get the workflow run url. Exiting."
128+ # exit 1
129+ # fi
130+
131+ # # Wait for workflow completion
132+ # while true; do
133+ # sleep 10
134+ # response=$(curl -s -L \
135+ # -H "Authorization: Bearer ${{ secrets.PR_TRIGGER_PAT }}" \
136+ # -H "Accept: application/vnd.github+json" \
137+ # $workflow_run_url)
138+
139+ # status=$(echo "$response" | jq -r '.status')
140+ # conclusion=$(echo "$response" | jq -r '.conclusion')
141+
142+ # if [ "$status" == "completed" ]; then
143+ # if [ "$conclusion" == "success" ]; then
144+ # echo "Workflow completed successfully."
145+ # exit 0
146+ # else
147+ # echo "Workflow failed with conclusion: $conclusion"
148+ # exit 1
149+ # fi
150+ # fi
151+
152+ # echo "Workflow still running..."
153+ # sleep 20
154+ # done
0 commit comments