Skip to content

Notify Slack on successful Pages deploy#12

Merged
hayarobi merged 1 commit into
mainfrom
ci/slack-deploy-notification
Jun 29, 2026
Merged

Notify Slack on successful Pages deploy#12
hayarobi merged 1 commit into
mainfrom
ci/slack-deploy-notification

Conversation

@ultrafellen

Copy link
Copy Markdown
Member

Summary

Adds a Notify Slack step to the deploy job in deploy.yml. After a successful GitHub Pages deploy (if: success()), it posts a deploy log to Slack via chat.postMessage.

Message format (matches the team's existing convention):

[Docs] docs.hpp.io deployed successfully

```

https://github.com/hpp-io/docs/commit/


## How it works
- Credentials come from repo secrets **`SLACK_BOT_TOKEN`** + **`SLACK_CHANNEL_ID`** (already set on this repo).
- The commit message is passed via an **env var** (not inline `${{ }}`) and escaped with **`jq --arg`** → no script injection, safe with backticks/quotes/newlines.
- The step **fails the build** (`jq -e '.ok'`) if Slack returns an error (`not_in_channel`, `invalid_auth`, …) — no silent failures.
- Success-only (no failure notifications, per request).

## Prerequisites (already handled / to confirm)
- [x] Repo secrets `SLACK_BOT_TOKEN`, `SLACK_CHANNEL_ID` set.
- [x] Token validated via `auth.test` → bot `hpp_ops_bot` (workspace HPP/Aergo).
- [ ] Bot must have **`chat:write`** scope and be **invited to the channel** (couldn't verify non-destructively — the same bot already posts hub deploys to this channel, so this is expected to be in place).

## Test Plan
- [x] `deploy.yml` validates as YAML; `deploy` job steps = [Deploy to GitHub Pages, Notify Slack].
- [x] `jq` payload dry-run produces valid JSON and the expected Slack text.
- [ ] First real run: merge to `main` → Pages deploy → confirm the message lands in the channel (a misconfig will show as a red deploy).

> Note: this step only runs on push to `main`, so the Slack message is exercised on the next merge/deploy, not on this PR's CI.

Add a "Notify Slack" step to the deploy job that posts a deploy log to
Slack via chat.postMessage after a successful GitHub Pages deploy
(if: success() only).

- Credentials come from repo secrets (SLACK_BOT_TOKEN, SLACK_CHANNEL_ID).
- The commit message is passed via env (not inline ${{ }}) and escaped
  with jq to prevent script injection.
- The step fails loudly (jq -e '.ok') if Slack returns an error, e.g.
  not_in_channel or invalid_auth.

Message format: "[Docs] docs.hpp.io deployed successfully" + the commit
message in a code block + the commit URL.
@ultrafellen ultrafellen requested a review from hayarobi June 26, 2026 16:10
@hayarobi

Copy link
Copy Markdown
Member

혹시 어느 슬랙 채널로 알림이 오는지 알 수 있을까요?

@ultrafellen

Copy link
Copy Markdown
Member Author

#dev_logs 로 설정해뒀습니다.

@hayarobi hayarobi left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@hayarobi hayarobi merged commit 1f2ae67 into main Jun 29, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants