From 4531e5eba8db6191221953ef78a0cd84b950f62f Mon Sep 17 00:00:00 2001 From: Ben Larabie Date: Thu, 21 Mar 2024 15:43:06 -0400 Subject: [PATCH] Adding error detection around the k8s rollout (#2145) * adding error detection around the k8s rollout * fixing for shellcheck --- .github/workflows/docker.yaml | 7 +------ scripts/callManifestsRollout.sh | 17 +++++++++++++++++ 2 files changed, 18 insertions(+), 6 deletions(-) create mode 100755 scripts/callManifestsRollout.sh diff --git a/.github/workflows/docker.yaml b/.github/workflows/docker.yaml index 5fa4e2f343..5ff8c67f88 100644 --- a/.github/workflows/docker.yaml +++ b/.github/workflows/docker.yaml @@ -57,12 +57,7 @@ jobs: - name: Rollout in Kubernetes run: | - PAYLOAD={\"ref\":\"main\",\"inputs\":{\"docker_sha\":\"${GITHUB_SHA::7}\"}} - curl -L -X POST -H "Accept: application/vnd.github+json" \ - -H "Authorization: Bearer $WORKFLOW_PAT" \ - -H "X-GitHub-Api-Version: 2022-11-28" \ - https://api.github.com/repos/cds-snc/notification-manifests/actions/workflows/api-rollout-k8s-staging.yaml/dispatches \ - -d $PAYLOAD + ./scripts/callManifestsRollout.sh ${GITHUB_SHA::7} - name: my-app-install token id: notify-pr-bot diff --git a/scripts/callManifestsRollout.sh b/scripts/callManifestsRollout.sh new file mode 100755 index 0000000000..29229ea093 --- /dev/null +++ b/scripts/callManifestsRollout.sh @@ -0,0 +1,17 @@ +#!/bin/bash +GITHUB_SHA=$1 +PAYLOAD="{\"ref\":\"main\",\"inputs\":{\"docker_sha\":\"$GITHUB_SHA\"}}" + + +RESPONSE=$(curl -w '%{http_code}\n' \ + -o /dev/null -s \ + -L -X POST -H "Accept: application/vnd.github+json" \ + -H "Authorization: Bearer $WORKFLOW_PAT" \ + -H "X-GitHub-Api-Version: 2022-11-28" \ + https://api.github.com/repos/cds-snc/notification-manifests/actions/workflows/api-rollout-k8s-staging.yaml/dispatches \ + -d "$PAYLOAD") + +if [ "$RESPONSE" != 204 ]; then + echo "ERROR CALLING MANIFESTS ROLLOUT: HTTP RESPONSE: $RESPONSE" + exit 1 +fi