Skip to content

docs: update CONTRIBUTING.md with guidelines-bot details and review expectations #791

docs: update CONTRIBUTING.md with guidelines-bot details and review expectations

docs: update CONTRIBUTING.md with guidelines-bot details and review expectations #791

Workflow file for this run

name: Reviewer Bot
on:
# Trigger when issues are opened, labeled, or closed
issues:
types: [opened, labeled, closed]
# Trigger when PRs are opened, labeled, or closed
# Using pull_request_target to handle PRs from forks with write permissions
pull_request_target:
types: [opened, labeled, closed]
# Trigger on comments for bot commands
issue_comment:
types: [created]
# Trigger on PR review submissions
pull_request_review:
types: [submitted]
# Nightly check for overdue reviews (runs at 9 AM UTC daily)
schedule:
- cron: '0 9 * * *'
# Allow manual triggering (useful for testing/debugging)
workflow_dispatch:
inputs:
action:
description: 'Action to perform'
required: true
default: 'sync-members'
type: choice
options:
- sync-members
- show-state
- check-overdue
# Ensure only one instance runs at a time per issue/PR
# This prevents race conditions when both 'opened' and 'labeled' fire together
concurrency:
group: reviewer-bot-${{ github.event.issue.number || github.event.pull_request.number || 'manual' }}
cancel-in-progress: false
permissions:
issues: write
pull-requests: write
contents: write
env:
# Issue number where bot state is stored (create this issue first!)
# The issue should be pinned and titled something like "📊 Reviewer Bot State"
STATE_ISSUE_NUMBER: "314"
jobs:
reviewer-bot:
runs-on: ubuntu-latest
# Skip if:
# - Comment is from a bot (prevent infinite loops)
# - The issue/PR being acted on is the state issue itself (314)
# Always run for schedule events
if: >
github.event_name == 'schedule' ||
github.event_name == 'workflow_dispatch' ||
((github.event_name != 'issue_comment' || github.event.comment.user.type != 'Bot') &&
((github.event.issue.number || github.event.pull_request.number || 0) != 314))
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Install uv
uses: astral-sh/setup-uv@v6
- name: Run reviewer bot
id: bot
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
STATE_ISSUE_NUMBER: ${{ env.STATE_ISSUE_NUMBER }}
# Pass event context to the script
EVENT_NAME: ${{ github.event_name }}
EVENT_ACTION: ${{ github.event.action }}
# Issue/PR context
ISSUE_NUMBER: ${{ github.event.issue.number || github.event.pull_request.number }}
ISSUE_TITLE: ${{ github.event.issue.title || github.event.pull_request.title }}
ISSUE_AUTHOR: ${{ github.event.issue.user.login || github.event.pull_request.user.login }}
ISSUE_HTML_URL: ${{ github.event.issue.html_url || github.event.pull_request.html_url }}
IS_PULL_REQUEST: ${{ github.event.pull_request != null || (github.event.issue.pull_request != null) }}
# Label context (for labeled events)
LABEL_NAME: ${{ github.event.label.name }}
# Comment context (for issue_comment events)
COMMENT_BODY: ${{ github.event.comment.body }}
COMMENT_AUTHOR: ${{ github.event.comment.user.login }}
COMMENT_ID: ${{ github.event.comment.id }}
# Review context (for pull_request_review events)
REVIEW_STATE: ${{ github.event.review.state }}
REVIEW_AUTHOR: ${{ github.event.review.user.login }}
PR_IS_CROSS_REPOSITORY: ${{ github.event.pull_request != null && github.event.pull_request.head.repo.full_name != github.repository }}
# For manual dispatch
MANUAL_ACTION: ${{ github.event.inputs.action }}
# Repository info
REPO_OWNER: ${{ github.repository_owner }}
REPO_NAME: ${{ github.event.repository.name }}
# Labels on the issue/PR (as JSON)
ISSUE_LABELS: ${{ toJson(github.event.issue.labels.*.name || github.event.pull_request.labels.*.name) }}
run: |
uv run python scripts/reviewer_bot.py
- name: Write reconcile context artifact
if: ${{ success() && github.event_name == 'pull_request_review' && github.event.action == 'submitted' }}
env:
RECONCILE_CONTEXT_PATH: ${{ runner.temp }}/reviewer-bot/reconcile-context.json
RECONCILE_EVENT_NAME: ${{ github.event_name }}
RECONCILE_EVENT_ACTION: ${{ github.event.action }}
RECONCILE_PR_NUMBER: ${{ github.event.pull_request.number }}
RECONCILE_HEAD_SHA: ${{ github.event.pull_request.head.sha }}
RECONCILE_SOURCE_RUN_ID: ${{ github.run_id }}
run: |
mkdir -p "$(dirname "${RECONCILE_CONTEXT_PATH}")"
cat > "${RECONCILE_CONTEXT_PATH}" <<EOF
{
"schema_version": 1,
"event_name": "${RECONCILE_EVENT_NAME}",
"event_action": "${RECONCILE_EVENT_ACTION}",
"pr_number": ${RECONCILE_PR_NUMBER},
"head_sha": "${RECONCILE_HEAD_SHA}",
"source_run_id": ${RECONCILE_SOURCE_RUN_ID}
}
EOF
- name: Upload reconcile context artifact
if: ${{ success() && github.event_name == 'pull_request_review' && github.event.action == 'submitted' }}
uses: actions/upload-artifact@v4
with:
name: reviewer-bot-reconcile-context-${{ github.run_id }}
path: ${{ runner.temp }}/reviewer-bot/reconcile-context.json
retention-days: 1
if-no-files-found: error