From e1fcd4c00b96dc589911fa940af272b3e33ed56f Mon Sep 17 00:00:00 2001 From: Johannes Date: Wed, 8 Jul 2026 14:20:32 -0400 Subject: [PATCH] fix(guide-ci): make Slack notify step non-fatal + reachability probe The Notify Slack step could fail the whole job (turning a successful deploy red, as just happened). A notification must never fail a deploy: - continue-on-error: true on the step - curl captures HTTP code and never propagates a non-zero exit (|| echo) - logs "slack notify HTTP: " so we can see if the runner reaches Slack - first commit line via ${VAR%%$'\n'*} param-expansion (no head pipe) Co-Authored-By: Claude Opus 4.8 --- .gitea/workflows/cd-develop.yml | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/.gitea/workflows/cd-develop.yml b/.gitea/workflows/cd-develop.yml index 663b49f..f0d2934 100644 --- a/.gitea/workflows/cd-develop.yml +++ b/.gitea/workflows/cd-develop.yml @@ -86,6 +86,7 @@ jobs: # org secret; if unset the step no-ops so forks/dry-runs don't error. - name: Notify Slack (#hiveops-dev-deploy) if: always() + continue-on-error: true # a notification must NEVER fail the deploy env: SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} JOB_STATUS: ${{ job.status }} @@ -98,7 +99,8 @@ jobs: run: | [ -z "$SLACK_WEBHOOK_URL" ] && { echo "no SLACK_WEBHOOK_URL secret — skipping"; exit 0; } SHORT="${SHA:0:8}" - SUBJECT="$(printf '%s' "$COMMIT_MSG" | head -n1 | tr -d '"\\' | cut -c1-100)" + FIRST="${COMMIT_MSG%%$'\n'*}" # first line via param-expansion (no pipe) + SUBJECT="$(printf '%s' "$FIRST" | tr -d '"\\' | cut -c1-100)" if [ "$JOB_STATUS" = "success" ]; then COLOR="#2eb67d"; TITLE=":white_check_mark: guide → bcos.dev deployed" else @@ -106,4 +108,6 @@ jobs: fi PAYLOAD=$(printf '{"attachments":[{"color":"%s","blocks":[{"type":"section","text":{"type":"mrkdwn","text":"*%s*"}},{"type":"section","fields":[{"type":"mrkdwn","text":"*Commit*\\n`%s` %s"},{"type":"mrkdwn","text":"*Branch*\\n%s"},{"type":"mrkdwn","text":"*By*\\n%s"},{"type":"mrkdwn","text":"*Run*\\n#%s"}]},{"type":"actions","elements":[{"type":"button","text":{"type":"plain_text","text":"View run"},"url":"%s"}]}]}]}' \ "$COLOR" "$TITLE" "$SHORT" "$SUBJECT" "$REF_NAME" "$ACTOR" "$RUN_NUMBER" "$RUN_URL") - curl -s -X POST -H 'Content-type: application/json' --data "$PAYLOAD" "$SLACK_WEBHOOK_URL" + # Non-fatal: capture the HTTP code, never let curl's exit fail the step. + code=$(curl -s -o /dev/null -w '%{http_code}' --max-time 15 -X POST -H 'Content-type: application/json' --data "$PAYLOAD" "$SLACK_WEBHOOK_URL" || echo "curl-error") + echo "slack notify HTTP: $code (200 = card posted; anything else = runner could not reach Slack)"