Merge pull request 'ci(guide): Slack dev-deploy notifications to #hiveops-dev-deploy' (#8) from feat/slack-dev-deploy-notify into develop
CD - Develop (guide → bcos.dev) / build-and-deploy (push) Failing after 33m55s
CD - Develop (guide → bcos.dev) / build-and-deploy (push) Failing after 33m55s
This commit was merged in pull request #8.
This commit is contained in:
@@ -80,3 +80,30 @@ jobs:
|
||||
sleep 5
|
||||
done
|
||||
echo "::error::guide did not report healthy after deploy"; exit 1
|
||||
|
||||
# Posts a ✅/🔴 card to #hiveops-dev-deploy on every run (deploy result). Runs even on
|
||||
# failure so a broken build/deploy/smoke is announced, not silent. SLACK_WEBHOOK_URL is an
|
||||
# org secret; if unset the step no-ops so forks/dry-runs don't error.
|
||||
- name: Notify Slack (#hiveops-dev-deploy)
|
||||
if: always()
|
||||
env:
|
||||
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
|
||||
JOB_STATUS: ${{ job.status }}
|
||||
ACTOR: ${{ github.actor }}
|
||||
REF_NAME: ${{ github.ref_name }}
|
||||
SHA: ${{ github.sha }}
|
||||
RUN_NUMBER: ${{ github.run_number }}
|
||||
RUN_URL: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}
|
||||
COMMIT_MSG: ${{ github.event.head_commit.message }}
|
||||
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)"
|
||||
if [ "$JOB_STATUS" = "success" ]; then
|
||||
COLOR="#2eb67d"; TITLE=":white_check_mark: guide → bcos.dev deployed"
|
||||
else
|
||||
COLOR="#e01e5a"; TITLE=":red_circle: guide → bcos.dev deploy FAILED ($JOB_STATUS)"
|
||||
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"
|
||||
|
||||
Reference in New Issue
Block a user