83 lines
3.3 KiB
Markdown
83 lines
3.3 KiB
Markdown
# slack-relay (upc-dev)
|
|
|
|
[slack-relay](https://git.forteapps.net/Forte/slack-relay) receives signed
|
|
outgoing webhooks from [ai-git-bot](../ai-git-bot/README.md) and posts them to
|
|
Slack as Block Kit messages. ai-git-bot has no templating of its own — it sends
|
|
a fixed `{schemaVersion, eventType, repository, data}` envelope — and Slack
|
|
wants `text`/`blocks`, so something has to translate between them.
|
|
|
|
Deployed from the shared `forteapp` chart in `forte-helm`; there is no chart in
|
|
this repo.
|
|
|
|
| | |
|
|
|---|---|
|
|
| Image | `git.forteapps.net/forte/slack-relay` |
|
|
| Chart | `forte-helm/forteapp` |
|
|
| Values | `helm-prod-values/slack-relay/values.yaml` |
|
|
| Secret | `slack-relay-secrets` (SealedSecret) |
|
|
| Endpoint | `http://slack-relay-app.slack-relay.svc.cluster.local:3000/hooks/ai-git-bot` |
|
|
|
|
The service is ClusterIP-only — no ingress, no certificate, nothing exposed
|
|
outside the cluster. The HMAC signature is therefore the only authentication:
|
|
any pod can reach the endpoint, but only a caller holding
|
|
`AIGITBOT_WEBHOOK_SECRET` can make it post.
|
|
|
|
## 1. Seal the secret
|
|
|
|
The plaintext template lives in the gitignored
|
|
`private/upc-dev/slack-relay-secrets.yaml`, with `AIGITBOT_WEBHOOK_SECRET`
|
|
already generated. Paste the Slack incoming webhook URL into it, then:
|
|
|
|
```bash
|
|
kubeseal --format=yaml --namespace=slack-relay \
|
|
< private/upc-dev/slack-relay-secrets.yaml \
|
|
> apps/overlays/upc-dev/slack-relay/slack-relay-secrets-sealed.yaml
|
|
```
|
|
|
|
Then uncomment `slack-relay-secrets-sealed.yaml` in `kustomization.yaml` and
|
|
commit.
|
|
|
|
| Key | Purpose |
|
|
|---|---|
|
|
| `SLACK_WEBHOOK_URL` | Slack incoming webhook; fixed to one channel at install time |
|
|
| `AIGITBOT_WEBHOOK_SECRET` | Must match the endpoint secret configured in ai-git-bot |
|
|
|
|
To post via a bot token instead (multi-channel routing, threading), swap
|
|
`SLACK_WEBHOOK_URL` for `SLACK_BOT_TOKEN` + `SLACK_CHANNEL` in the secret and
|
|
add `SLACK_MODE=bot` to `app.extraEnv` in the values file.
|
|
|
|
## 2. Configure the ai-git-bot endpoint
|
|
|
|
**System settings → Outgoing webhooks → add endpoint**:
|
|
|
|
- URL: `http://slack-relay-app.slack-relay.svc.cluster.local:3000/hooks/ai-git-bot`
|
|
- Secret: the `AIGITBOT_WEBHOOK_SECRET` value
|
|
- Events: `prworkflow.completed`, `prworkflow.failed`,
|
|
`prworkflow.agentreview.finding.detected`, `issueassignment.completed`,
|
|
`issueassignment.failed` (skip the `*.started` events unless you want the noise)
|
|
- Scope: leave empty for all bots and repositories
|
|
|
|
## 3. Verify
|
|
|
|
```bash
|
|
kubectl -n slack-relay port-forward svc/slack-relay-app 3000:3000
|
|
AIGITBOT_WEBHOOK_SECRET=... node scripts/send-test-event.js http://localhost:3000
|
|
```
|
|
|
|
(`scripts/send-test-event.js` lives in the slack-relay repo.) A real check is
|
|
ai-git-bot's own delivery log, which shows the response code per delivery.
|
|
|
|
## Reading the logs
|
|
|
|
The relay logs one JSON line per delivery. The status it returns is a signal to
|
|
ai-git-bot's retry loop: `502` means "Slack was down, retry me", while a
|
|
permanent Slack rejection is answered with `200` and logged at error level,
|
|
because retrying it could never succeed. So `"msg":"slack rejected the message,
|
|
dropping it"` is the line to alert on — it means messages are being lost.
|
|
|
|
## Image tag
|
|
|
|
The values file currently pins `latest` with `pullPolicy: Always`. Once the
|
|
release workflow has produced a `vX.Y.Z` tag, switch to it: Renovate will then
|
|
keep the values file current and rollbacks become possible.
|