mirror of
https://github.com/supabase/supabase.git
synced 2026-12-03 23:18:57 +00:00
## Problem Not every docs PR gets posted in #team-docs, so some never get noticed by the docs team. Tracked in [DOCS-1683](https://linear.app/supabase/issue/DOCS-1683), the first stage of the docs PR review workflow project. ## Solution A new workflow, `.github/workflows/docs-pr-alert.yml`, posts a one-line message to #team-docs-alerts whenever a PR that changes `apps/docs/**` becomes ready for review: | What happens | Posts? | | --- | --- | | Opened as a draft | No | | Draft marked ready for review | Yes | | Opened as ready (not a draft) | Yes, when it's opened | | Ready, then draft, then ready again | Yes, each time it's marked ready | The message links the PR title and says whether the PR is internal or external (from a fork): ``` #00000 Add RLS examples to the auth guide · External ``` Key choices: - **`pull_request_target`** so fork PRs can read the webhook secret. The workflow only reads the event payload: it never checks out or runs PR code, and has `permissions: {}`. It's added to the zizmor `dangerous-triggers` allowlist alongside `external-pr-comment.yml` and the other `pull_request_target` workflows. - **Path filter instead of the `documentation` label**, because the labeler adds the label in a separate run and it may not be there yet when this runs. - **Reuses the existing `SLACK_DOCS_WEBHOOK_URL` secret** from `docs-master-alert.yml` (#53366), which already posts to #team-docs-alerts. No new Slack app or secret is needed. The workflow still skips quietly if the secret is missing. ## Review instructions 1. Read `.github/workflows/docs-pr-alert.yml` and confirm it never checks out or executes PR code. 2. Confirm the `zizmor.yml` change only adds this workflow to the allowlist. Checked locally with actionlint, zizmor 1.26.1 (same config as CI), and Prettier. ## Checklist Check all before review: - [x] I have read [CONTRIBUTING.md](https://github.com/supabase/supabase/blob/master/CONTRIBUTING.md) - [ ] If I wrote a new docs topic or edited an existing topic, I used the `/write-the-docs` or `/edit-the-docs` skill, which applies the docs [style guide](https://github.com/supabase/supabase/tree/master/apps/docs/style-guide) 🤖 Generated with [Claude Code](https://claude.com/claude-code) --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
47 lines
1.8 KiB
YAML
47 lines
1.8 KiB
YAML
name: Post docs PRs to Slack
|
|
|
|
# Posts a docs PR to #team-docs-alerts whenever it's ready for review: when
|
|
# it's opened as ready, and every time a draft is marked ready. Reuses the
|
|
# webhook from docs-master-alert.yml.
|
|
# pull_request_target is used so fork PRs can read the webhook secret. This
|
|
# workflow only reads the event payload. It never checks out or runs PR code.
|
|
on:
|
|
pull_request_target:
|
|
types: [opened, ready_for_review]
|
|
paths:
|
|
- 'apps/docs/**'
|
|
|
|
permissions: {}
|
|
|
|
jobs:
|
|
post-to-slack:
|
|
runs-on: ubuntu-latest
|
|
if: github.event.pull_request.draft == false
|
|
steps:
|
|
- name: Post to Slack
|
|
uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0
|
|
env:
|
|
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_DOCS_WEBHOOK_URL }}
|
|
with:
|
|
script: |
|
|
const webhookUrl = process.env.SLACK_WEBHOOK_URL
|
|
if (!webhookUrl) {
|
|
core.notice('SLACK_DOCS_WEBHOOK_URL is not set, skipping.')
|
|
return
|
|
}
|
|
|
|
const pr = context.payload.pull_request
|
|
const isExternal = !pr.head.repo || pr.head.repo.full_name !== pr.base.repo.full_name
|
|
const escape = (text) =>
|
|
text.replace(/&/g, '&').replace(/</g, '<').replace(/>/g, '>')
|
|
const text = `<${pr.html_url}|#${pr.number} ${escape(pr.title)}> · ${isExternal ? 'External' : 'Internal'}`
|
|
|
|
const response = await fetch(webhookUrl, {
|
|
method: 'POST',
|
|
headers: { 'Content-Type': 'application/json' },
|
|
body: JSON.stringify({ text, unfurl_links: false }),
|
|
})
|
|
if (!response.ok) {
|
|
core.setFailed(`Slack returned ${response.status}: ${await response.text()}`)
|
|
}
|