From 37d4a2f7d743193c65cb595b2f15f3c92e06e4a2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Paul=20Gro=C3=9Fmann?= Date: Mon, 6 Jul 2026 18:11:19 +0200 Subject: [PATCH 1/3] fix: permission part in script to create PubSub resources --- scripts/create-pubsub-resources.sh | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/scripts/create-pubsub-resources.sh b/scripts/create-pubsub-resources.sh index 282533c..7094645 100755 --- a/scripts/create-pubsub-resources.sh +++ b/scripts/create-pubsub-resources.sh @@ -88,33 +88,34 @@ done #ACCESS echo "Granting Publisher Access via curl (Targeting: $REGION)..." -GPARESPONSE=$(curl -sk -w "\n%{http_code}" -X PUT "${BASE_URL}/projects/${PROJECT_ID}/regions/${REGION}/topics/${TOPIC_ID}/publishers/$PUBLISHER_MAIL" \ +PUBLISHER_RESPONSE=$(curl -sk -w "\n%{http_code}" -X PATCH "${BASE_URL}/projects/${PROJECT_ID}/regions/${REGION}/topics/${TOPIC_ID}/publishers" \ -H "Authorization: Bearer $TOKEN" \ -H "Content-Type: application/json" \ - -d "{\"displayName\": \"ci-topic-$(date +%s)\"}") + -d "{\"emailAddress\": \"$PUBLISHER_MAIL\"}") + +HTTP_STATUS=$(echo "$PUBLISHER_RESPONSE" | tail -n 1) +PUBLISHER_BODY=$(echo "$PUBLISHER_RESPONSE" | sed '$d') if [ "$HTTP_STATUS" -ne 202 ] && [ "$HTTP_STATUS" -ne 200 ]; then - echo "API Error (HTTP $HTTP_STATUS)" - echo "Response Granting Publisher Access Body: $GPARESPONSE" + echo "API Error Granting Publisher Access (HTTP $HTTP_STATUS)" + echo "Response Granting Publisher Access Body: $PUBLISHER_BODY" exit 1 fi -echo "Response SUBSCRIPTION Body: $GPARESPONSE" - echo "Granting Subscriber Access via curl (Targeting: $REGION)..." -GSARESPONSE=$(curl -sk -w "\n%{http_code}" -X PUT "${BASE_URL}/projects/${PROJECT_ID}/regions/${REGION}/topics/${TOPIC_ID}/subscriptions/$SUBSCRIPTION_ID/subscribers/$PUBLISHER_MAIL" \ +SUBSCRIBER_RESPONSE=$(curl -sk -w "\n%{http_code}" -X PATCH "${BASE_URL}/projects/${PROJECT_ID}/regions/${REGION}/topics/${TOPIC_ID}/subscriptions/${SUBSCRIPTION_ID}/subscribers" \ -H "Authorization: Bearer $TOKEN" \ -H "Content-Type: application/json" \ - -d "{\"displayName\": \"ci-topic-$(date +%s)\"}") + -d "{\"emailAddress\": \"$PUBLISHER_MAIL\"}") +HTTP_STATUS=$(echo "$SUBSCRIBER_RESPONSE" | tail -n 1) +SUBSCRIBER_BODY=$(echo "$SUBSCRIBER_RESPONSE" | sed '$d') if [ "$HTTP_STATUS" -ne 202 ] && [ "$HTTP_STATUS" -ne 200 ]; then - echo "API Error (HTTP $HTTP_STATUS)" - echo "Response Granting Subscriber Access Body: $GSARESPONSE" + echo "API Error Granting Subscriber Access (HTTP $HTTP_STATUS)" + echo "Response Granting Subscriber Access Body: $SUBSCRIBER_BODY" exit 1 fi -echo "Response SUBSCRIPTION Body: $GSARESPONSE" - echo "Waiting for access permissions to propagate..." -sleep 15 \ No newline at end of file +sleep 5 \ No newline at end of file From 10f5fd2e56478c0e0a926339cffb729dce158ca3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Paul=20Gro=C3=9Fmann?= Date: Mon, 6 Jul 2026 18:33:01 +0200 Subject: [PATCH 2/3] fix: corrected api response codes in create-pubsub-resources.sh --- scripts/create-pubsub-resources.sh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/scripts/create-pubsub-resources.sh b/scripts/create-pubsub-resources.sh index 7094645..9baa969 100755 --- a/scripts/create-pubsub-resources.sh +++ b/scripts/create-pubsub-resources.sh @@ -26,7 +26,7 @@ HTTP_STATUS=$(echo "$TOPICRESPONSE" | tail -n 1) TOPICBODY=$(echo "$TOPICRESPONSE" | sed '$d') echo "Response Body: $TOPICBODY" -if [ "$HTTP_STATUS" -ne 202 ] && [ "$HTTP_STATUS" -ne 200 ]; then +if [ "$HTTP_STATUS" -ne 202 ]; then echo "API Error (HTTP $HTTP_STATUS)" echo "Response Topic Body: $TOPICBODY" exit 1 @@ -61,7 +61,7 @@ HTTP_STATUS=$(echo "$SUBRESPONSE" | tail -n 1) SUBBODY=$(echo "$SUBRESPONSE" | sed '$d') echo "Response Body: $SUBBODY" -if [ "$HTTP_STATUS" -ne 202 ] && [ "$HTTP_STATUS" -ne 200 ]; then +if [ "$HTTP_STATUS" -ne 202 ]; then echo "API Error (HTTP $HTTP_STATUS)" echo "Response SUBSCRIPTION Body: $SUBBODY" exit 1 @@ -96,7 +96,7 @@ PUBLISHER_RESPONSE=$(curl -sk -w "\n%{http_code}" -X PATCH "${BASE_URL}/projects HTTP_STATUS=$(echo "$PUBLISHER_RESPONSE" | tail -n 1) PUBLISHER_BODY=$(echo "$PUBLISHER_RESPONSE" | sed '$d') -if [ "$HTTP_STATUS" -ne 202 ] && [ "$HTTP_STATUS" -ne 200 ]; then +if [ "$HTTP_STATUS" -ne 202 ]; then echo "API Error Granting Publisher Access (HTTP $HTTP_STATUS)" echo "Response Granting Publisher Access Body: $PUBLISHER_BODY" exit 1 @@ -111,7 +111,7 @@ SUBSCRIBER_RESPONSE=$(curl -sk -w "\n%{http_code}" -X PATCH "${BASE_URL}/project HTTP_STATUS=$(echo "$SUBSCRIBER_RESPONSE" | tail -n 1) SUBSCRIBER_BODY=$(echo "$SUBSCRIBER_RESPONSE" | sed '$d') -if [ "$HTTP_STATUS" -ne 202 ] && [ "$HTTP_STATUS" -ne 200 ]; then +if [ "$HTTP_STATUS" -ne 202 ]; then echo "API Error Granting Subscriber Access (HTTP $HTTP_STATUS)" echo "Response Granting Subscriber Access Body: $SUBSCRIBER_BODY" exit 1 From 4921ea2bb9025adddaeac87b1b89ea0231269b57 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Paul=20Gro=C3=9Fmann?= Date: Mon, 6 Jul 2026 18:36:09 +0200 Subject: [PATCH 3/3] feat: better error messages for github pipelines in create-pubsub-resources.sh --- scripts/create-pubsub-resources.sh | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/scripts/create-pubsub-resources.sh b/scripts/create-pubsub-resources.sh index 9baa969..3be9f5a 100755 --- a/scripts/create-pubsub-resources.sh +++ b/scripts/create-pubsub-resources.sh @@ -11,7 +11,7 @@ TOKEN=$(stackit auth activate-service-account --only-print-access-token --servic echo "SERVICE_ACCOUNT_TOKEN=$TOKEN" >> $GITHUB_ENV if [ -z "$TOKEN" ] || [ ${#TOKEN} -lt 20 ]; then - echo "Error: Retrieved token is empty or too short." + echo "::error file=scripts/create-pubsub-resources.sh::Retrieved token is empty or too short." exit 1 fi @@ -27,8 +27,7 @@ TOPICBODY=$(echo "$TOPICRESPONSE" | sed '$d') echo "Response Body: $TOPICBODY" if [ "$HTTP_STATUS" -ne 202 ]; then - echo "API Error (HTTP $HTTP_STATUS)" - echo "Response Topic Body: $TOPICBODY" + echo "::error file=scripts/create-pubsub-resources.sh::Failed to create topic (HTTP $HTTP_STATUS) - Response: $TOPICBODY" exit 1 fi @@ -44,7 +43,7 @@ for i in {1..50}; do break fi if [ "$i" -eq 50 ]; then - echo "Topic did not become active in time." + echo "::error file=scripts/create-pubsub-resources.sh::Topic $TOPIC_ID did not become active in time." exit 1 fi sleep 5 @@ -62,8 +61,7 @@ SUBBODY=$(echo "$SUBRESPONSE" | sed '$d') echo "Response Body: $SUBBODY" if [ "$HTTP_STATUS" -ne 202 ]; then - echo "API Error (HTTP $HTTP_STATUS)" - echo "Response SUBSCRIPTION Body: $SUBBODY" + echo "::error file=scripts/create-pubsub-resources.sh::Failed to create subscription (HTTP $HTTP_STATUS) - Response: $SUBBODY" exit 1 fi @@ -79,7 +77,7 @@ for i in {1..50}; do break fi if [ "$i" -eq 50 ]; then - echo "Subscription did not become active in time." + echo "::error file=scripts/create-pubsub-resources.sh::Subscription $SUBSCRIPTION_ID did not become active in time." exit 1 fi sleep 5 @@ -97,8 +95,7 @@ HTTP_STATUS=$(echo "$PUBLISHER_RESPONSE" | tail -n 1) PUBLISHER_BODY=$(echo "$PUBLISHER_RESPONSE" | sed '$d') if [ "$HTTP_STATUS" -ne 202 ]; then - echo "API Error Granting Publisher Access (HTTP $HTTP_STATUS)" - echo "Response Granting Publisher Access Body: $PUBLISHER_BODY" + echo "::error file=scripts/create-pubsub-resources.sh::Failed to grant publisher access (HTTP $HTTP_STATUS) - Response: $PUBLISHER_BODY" exit 1 fi @@ -112,8 +109,7 @@ HTTP_STATUS=$(echo "$SUBSCRIBER_RESPONSE" | tail -n 1) SUBSCRIBER_BODY=$(echo "$SUBSCRIBER_RESPONSE" | sed '$d') if [ "$HTTP_STATUS" -ne 202 ]; then - echo "API Error Granting Subscriber Access (HTTP $HTTP_STATUS)" - echo "Response Granting Subscriber Access Body: $SUBSCRIBER_BODY" + echo "::error file=scripts/create-pubsub-resources.sh::Failed to grant subscriber access (HTTP $HTTP_STATUS) - Response: $SUBSCRIBER_BODY" exit 1 fi