Skip to content

Slack doc review notification#23313

Open
taroface wants to merge 2 commits into
mainfrom
slack-doc-review-notification
Open

Slack doc review notification#23313
taroface wants to merge 2 commits into
mainfrom
slack-doc-review-notification

Conversation

@taroface
Copy link
Copy Markdown
Contributor

Add a GitHub Action that sends a notification to Slack channel #doc_review when docs-prs is requested as a reviewer on a docs PR.

@taroface taroface requested a review from a team as a code owner May 13, 2026 17:09
@netlify
Copy link
Copy Markdown

netlify Bot commented May 13, 2026

Netlify Preview

Name Link
🔨 Latest commit 032eec1
🔍 Latest deploy log https://app.netlify.com/projects/cockroachdb-docs/deploys/6a0607a6bd99a40007d37995
😎 Deploy Preview https://deploy-preview-23313--cockroachdb-docs.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@netlify
Copy link
Copy Markdown

netlify Bot commented May 13, 2026

Deploy Preview for cockroachdb-api-docs canceled.

Name Link
🔨 Latest commit 032eec1
🔍 Latest deploy log https://app.netlify.com/projects/cockroachdb-api-docs/deploys/6a0607a64b2df500089ce4d4

@netlify
Copy link
Copy Markdown

netlify Bot commented May 13, 2026

Deploy Preview for cockroachdb-interactivetutorials-docs canceled.

Name Link
🔨 Latest commit 032eec1
🔍 Latest deploy log https://app.netlify.com/projects/cockroachdb-interactivetutorials-docs/deploys/6a0607a6b7c50b0008c2a1a7

Sends a notification to #doc_review channel when docs-prs team
is requested as a reviewer on a PR. The notification includes:
- PR title and number
- Author
- Total lines changed
- Direct link to the PR

Co-Authored-By: roachdev-claude <roachdev-claude-bot@cockroachlabs.com>
@taroface taroface force-pushed the slack-doc-review-notification branch from c46704f to 12f5e9f Compare May 13, 2026 17:11
@github-actions
Copy link
Copy Markdown

Files changed:

  • .github/workflows/slack-notify-doc-review.yml

@taroface taroface requested review from a team and removed request for a team May 13, 2026 17:13
Copy link
Copy Markdown
Contributor

@ebembi-crdb ebembi-crdb left a comment

Choose a reason for hiding this comment

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

A few issues to address before merging:

JSON injection via PR title

The curl payload constructs JSON by interpolating environment variables directly into a heredoc string. If a PR title contains a double quote or backslash, the JSON will be malformed. A crafted title could inject arbitrary JSON keys. Use jq to safely build the payload:

run: |
  jq -n \
    --arg title "$PR_TITLE" \
    --arg url "$PR_URL" \
    --arg author "$PR_AUTHOR" \
    --arg number "$PR_NUMBER" \
    --arg lines "$LINES_CHANGED" \
    '{pr_title: $title, pr_url: $url, pr_author: $author, pr_number: $number, lines_changed: $lines}' \
  | curl -X POST "$SLACK_WEBHOOK_URL" \
    -H 'Content-Type: application/json' \
    -d @-

Webhook URL is hardcoded in plaintext

The Slack webhook URL is committed directly into the workflow file. Anyone with read access to the repo can use it to post arbitrary messages to the Slack channel. This should be stored as a GitHub Actions secret (e.g., ${{ secrets.SLACK_DOC_REVIEW_WEBHOOK_URL }}).

The gh api call is unnecessary

The "Get PR details" step shells out to gh api to fetch additions/deletions, but github.event.pull_request in a review_requested event already includes additions and deletions. The whole first step could be replaced with:

LINES_CHANGED: ${{ github.event.pull_request.additions + github.event.pull_request.deletions }}

No error handling on the curl call

If the Slack webhook is down or returns an error, the workflow succeeds silently. Adding --fail-with-body to the curl call would surface failures.

- Use jq to safely construct JSON payload, preventing injection attacks
- Move webhook URL to GitHub secret instead of hardcoding
- Remove unnecessary gh api call, use github.event.pull_request directly
- Add --fail-with-body to curl for proper error handling

Co-Authored-By: roachdev-claude <roachdev-claude-bot@cockroachlabs.com>
@taroface
Copy link
Copy Markdown
Contributor Author

@ebembi-crdb TFTR! Let me know if this looks good now.

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