Built an automated workflow that triggers on GitHub PR events, orchestrates REST API calls and an LLM to generate structured PR documentation, and posts it back via authenticated API — reducing manual PR-writing time to zero.
This project is an automated n8n workflow designed to streamline the pull request documentation process. When a developer opens a PR, the workflow automatically intercepts the event, fetches the associated commit diffs using the GitHub REST API, and uses Google's Gemini API to generate a well-structured PR description based on a standard template. The description is then posted back to the PR via an authenticated API call.
- Automation: n8n (self-hosted on Azure VM, Ubuntu 24.04)
- LLM: Google Gemini API (free tier —
gemini-3.5-flash) - Version Control API: GitHub REST API
- Notifications: Gmail API (OAuth2)
- Hosting/Networking: DuckDNS + Caddy (HTTPS reverse proxy)
- Trigger: A GitHub Webhook listens for
Pull requestsevents (openedandreopenedactions; all other PR event types are acknowledged and ignored). - Fetch Data: The workflow calls the GitHub REST API (
GET /repos/{owner}/{repo}/pulls/{pull_number}/commits) to extract the list of commit messages. - LLM Processing: The commit data is passed to a Gemini node with a system prompt enforcing a strict PR template format (Title, Summary, grouped Changes with rationale, conditional Testing Notes).
- Post Update: A GitHub REST API call (
PATCH) updates the PR description with the generated summary. - Notifications: Success or failure triggers an email notification via Gmail API.
- Webhook Response: Every path (ignored, success, or failure) returns an explicit JSON response with an appropriate HTTP status code (
200/500), so GitHub's webhook delivery log always reflects the real outcome.
- n8n Environment: This workflow is designed for a self-hosted n8n instance (e.g., deployed via Docker).
- GitHub Webhooks: Configure a webhook in your repository settings pointing to your n8n Webhook URL, listening for Pull Request events.
- Authentication:
- A GitHub Personal Access Token (PAT) with
reposcope, to fetch commits and post the description. - A Google Gemini API key, to generate the PR description.
- Gmail OAuth2 credentials, for success/failure email notifications.
- A GitHub Personal Access Token (PAT) with
- Environment Variables: See
.env.examplefor required credentials.
Note on Performance: The PR generation process takes a moment to complete. This latency is primarily due to the rate limits and processing priority of the free tier of the Google Gemini API, rather than the automation pipeline itself. Upgrading to a production-grade paid API key would reduce the generation time to just a few seconds.
- Implementing a full OAuth App flow for wider distribution.
- Supporting custom PR templates on a per-repository basis.
- Handling
synchronizeevents to regenerate the description when new commits are pushed to an existing PR.


