A GitHub Action that automatically extracts Notion page and database information from Pull Request descriptions, converts them to Markdown format, and posts them as AI-ready context in PR comments.
- Automatic Detection: Scans PR descriptions for Notion URLs and fetches content
- AI-Ready Output: Converts Notion content to clean Markdown for AI tools and LLMs
- Smart Comments: Posts content in collapsible sections, updates automatically
- Error Handling: Gracefully handles inaccessible or invalid links
When using multiple AI agents for code reviews, each agent typically fetches Notion documentation independently, creating multiplied API costs and setup complexity.
This action fetches Notion content once and posts it as PR comments, making it instantly available to all AI agents without additional API calls.
Benefits: Cost efficient, zero per-agent setup, instant access, consistent context.
- A Notion workspace with pages/databases you want to reference
- A Notion integration with API access
- GitHub repository with Actions enabled
- Go to Notion Developers
- Click "New integration"
- Fill in the integration details:
- Name: Your integration name (e.g., "GitHub PR Comments")
- Workspace: Select your workspace
- Capabilities: Check "Read content" (other capabilities are not required)
- Click "Submit" and copy the Internal Integration Token
- Important: Keep this token secure - it will be used in GitHub Secrets
For each Notion page or database you want to access:
- Open the page/database in Notion
- Click "Share" in the top-right corner
- Click "Invite" and search for your integration name
- Select your integration and click "Invite"
📝 Note: You need to share each page/database individually that you want to reference in PRs. Child pages inherit permissions automatically.
- Go to your GitHub repository
- Navigate to Settings → Secrets and variables → Actions
- Click New repository secret
- Add the following secret:
- Name:
NOTION_TOKEN - Value: Your Notion integration token from Step 1
- Name:
🔒 Security: Never commit the Notion token directly to your repository. Always use GitHub Secrets.
Create .github/workflows/notion-to-github-comments.yml in your repository:
name: Notion to PR Comments
on:
pull_request:
types: [opened, edited]
jobs:
add-notion-comments:
runs-on: ubuntu-latest
permissions:
pull-requests: write # Required to post comments
contents: read # Required to read PR descriptions
steps:
- name: Add Notion Content to PR
uses: wasabeef/notion-to-github-comments@v1.2.0
with:
notion-token: ${{ secrets.NOTION_TOKEN }}
github-token: ${{ secrets.GITHUB_TOKEN }}Once set up, the action will automatically:
- Scan PR descriptions for Notion URLs when PRs are opened or edited
- Extract content from linked Notion pages and databases
- Convert to Markdown with proper formatting
- Post as comment with collapsible sections for each URL
## Overview
This PR implements the new user authentication flow.
## Related Documentation
- Design specs: https://www.notion.so/yourworkspace/auth-design-123abc
- API documentation: https://notion.so/yourworkspace/api-docs-456defThe action will create a comment like:
### 🤖 Notion Context (2 link(s) processed)
<details>
<summary> 📄 User Authentication Design</summary>
```markdown
# User Authentication Flow
## Overview
This document outlines the authentication system...
```
</details>| Input | Description | Required | Default |
|---|---|---|---|
notion-token |
Notion API integration token | ✅ | - |
github-token |
GitHub token for posting comments | ✅ | ${{ secrets.GITHUB_TOKEN }} |
- Pages: Full page content with nested blocks
- Databases: Table format with all visible properties
- Nested content: Child pages and blocks (up to API limits)
-
"Failed to fetch Notion content"
- Ensure the Notion page/database is shared with your integration
- Verify the
NOTION_TOKENsecret is correctly set - Check that the URL in PR description is accessible
-
"No Notion URLs found"
- Ensure URLs are in the PR description (not just in comments)
- Check URL format - should be
https://notion.so/...orhttps://www.notion.so/...
-
"Insufficient permissions"
- Verify GitHub Actions has
pull-requests: writepermission - Check if branch protection rules are blocking the action
- Verify GitHub Actions has
Contributions are welcome! Please see CONTRIBUTING.md for details.
This project is licensed under the MIT License - see the LICENSE file for details.
If you encounter any issues or have questions:
- Check the Issues page
- Create a new issue with detailed information
- Include relevant logs and configuration
- Notion API for providing the integration platform
- notion-to-md for Markdown conversion
- GitHub Actions community for inspiration and best practices