⚒️ Assign GitHub PR reviewers by file ownership with Supabase and Slack
⚡ 0 views · ⚒️ Engineering
💡 Pro Tip — If you need GitHub data beyond what the REST API gives you, ScraperNode has a repository scraper that extracts metadata at scale without token rate limits.
Description
Quick Overview
This workflow listens for GitHub pull request webhooks, looks up changed files and a reviewer roster in Supabase, selects matching reviewers based on file path ownership and last assignment time, then requests reviews in GitHub and notifies the reviewers in Slack.
How it works
- Receives a GitHub pull request webhook request.
- Extracts key PR details and filters to only process newly opened, non-draft PRs that are not created by bot accounts.
- Fetches the pull request’s changed files from the GitHub API and retrieves the full reviewer roster from Supabase.
- Matches changed file paths against each reviewer’s owned paths, excludes the PR author, and selects up to the configured maximum reviewers prioritizing those least recently assigned.
- Requests the selected reviewers on the pull request via the GitHub API.
- Sends each selected reviewer a direct Slack message with the PR title, author, and link, then updates their last-assigned timestamp in Supabase.
- If no matching reviewers are found, ends without assigning reviewers and records the “no reviewers” branch internally.
Setup
- Create a GitHub webhook for pull request events and point it to this workflow’s webhook URL (POST to
/github-pr-webhook). - Provide a GitHub personal access token (or equivalent) with permission to read PR files and request reviewers, then set
github_token,repo_owner, andrepo_namein the configuration values. - Connect your Supabase credentials and ensure a
reviewerstable exists withgithub_username,slack_user_id,owned_paths(comma-separated prefixes), andlast_assigned_atfields. - Connect Slack credentials and ensure each reviewer’s
slack_user_idis valid for direct messaging. - Adjust
max_reviewersand theowned_pathsmatching rules to fit your repository structure and review policy.
🔗 Nodes Used
HTTP Request, Slack, Webhook, Supabase
📥 Import
Download workflow.json and import into n8n:
Workflow menu → Import from File