Quick overview
This workflow receives GitHub pull request webhooks, looks up changed files and a Supabase-based reviewer ownership roster, selects the least recently assigned matching reviewers, requests them as reviewers on GitHub, and sends each selected reviewer a direct message in Slack.
How it works
- Receives a GitHub pull request webhook via an n8n webhook endpoint.
- Extracts PR details and only continues for newly opened, non-draft PRs that are not authored by bots.
- Fetches the PR’s changed file list from the GitHub REST API and loads the reviewer roster (GitHub username, Slack user ID, owned path prefixes, last assigned time) from Supabase.
- Matches changed file paths to reviewers’ owned path prefixes, excludes the PR author, sorts candidates by least recently assigned, and selects up to the configured maximum number of reviewers.
- If reviewers are found, requests them as reviewers on the PR using the GitHub API.
- Sends each selected reviewer a Slack DM with the PR title, author, and link, then updates the reviewer’s last_assigned_at field in Supabase for load balancing.
Setup
- Create a GitHub webhook for your repository that posts pull_request events to this workflow’s webhook URL.
- Provide a GitHub personal access token with permission to request reviewers, and set the repo owner/name and max reviewer count in the configuration values.
- Add a Supabase credential, create a reviewers table with fields for github_username, slack_user_id, owned_paths, and last_assigned_at, and update the table names if you don’t use the defaults.
- Add a Slack credential and ensure each reviewer’s Slack user ID is populated in Supabase so the workflow can send DMs.