A Django-based automation system that synchronizes your assigned GitHub issues directly to a Notion dashboard, making it easy to track and manage your tasks in one place.
- Direct Sync: Fetches GitHub issues and creates/updates Notion pages directly without local database
- Real-time Updates: Keeps issue status, labels, and content synchronized between GitHub and Notion
- Multiple Sync Options: Sync all assigned issues, specific repositories, or individual issues by URL
- Connection Testing: Built-in tools to verify GitHub and Notion API connectivity
- Management Commands: CLI commands for all sync operations
- Rate Limit Handling: Respects GitHub API rate limits and provides status information
notion_github_automation/
├── automation/ # Main automation logic
│ ├── management/commands/ # Django management commands
│ └── services.py # Direct sync orchestration (no database)
├── github_integration/ # GitHub API integration
│ └── services.py # GitHub API client and data parsing
├── notion_integration/ # Notion API integration
│ └── services.py # Notion API client and page management
└── notion_github_automation/ # Django project settings
└── settings.py # Configuration and API settings
- Python 3.8+
- Django 5.1+
- GitHub Personal Access Token
- Notion Integration Token
- Notion Database ID
-
Clone and Setup:
git clone <your-repo> cd notion_automation pip install django python-dotenv requests notion-client
-
Configure Environment: Create a
.env
file in the project root:SECRET_KEY=your-secret-key-here DEBUG=True # GitHub API Configuration GITHUB_TOKEN=your-github-personal-access-token GITHUB_USERNAME=your-github-username # Notion API Configuration NOTION_TOKEN=your-notion-integration-token NOTION_DATABASE_ID=your-notion-database-id LOG_LEVEL=INFO
-
Run Migrations:
python manage.py migrate
-
Create Superuser (optional, for admin access):
python manage.py createsuperuser
- Go to GitHub Settings → Developer settings → Personal access tokens
- Generate a new token with these scopes:
repo
(for private repos) orpublic_repo
(for public repos only)read:user
(to read user information)
- Copy the token to your
.env
file asGITHUB_TOKEN
-
Create Notion Integration:
- Go to Notion Developers
- Create a new integration
- Copy the Internal Integration Token to your
.env
file asNOTION_TOKEN
-
Create Notion Database:
- Create a new page in Notion
- Add a database with these properties:
Title
(Title)Issue ID
(Number)Status
(Select: Open, Closed)Repository
(Text)Assignee
(Text)GitHub URL
(URL)Labels
(Multi-select)Created Date
(Date)Updated Date
(Date)Closed Date
(Date)
-
Get Database ID:
- Share your database with your integration
- Copy the database ID from the URL:
https://notion.so/yourworkspace/DATABASE_ID?v=...
- Add it to your
.env
file asNOTION_DATABASE_ID
Full Sync (sync all assigned issues):
python manage.py sync_github_issues
Test API Connections:
python manage.py sync_github_issues --test-connections
Sync Single Issue by URL:
python manage.py sync_github_issues --github-url https://github.com/owner/repo/issues/123
Sync Repository Issues:
python manage.py sync_github_issues --repository owner/repo
Check Status:
python manage.py sync_github_issues --status
Scheduled Sync:
python manage.py sync_github_issues --sync-type scheduled
The Django admin is not needed for this direct sync approach. All operations are performed via command line.
Start the development server to access the Django admin:
python manage.py runserver
Variable | Description | Required |
---|---|---|
GITHUB_TOKEN |
GitHub Personal Access Token | Yes |
GITHUB_USERNAME |
Your GitHub username | Yes |
NOTION_TOKEN |
Notion Integration Token | Yes |
NOTION_DATABASE_ID |
Notion Database ID | Yes |
SECRET_KEY |
Django secret key | Yes |
DEBUG |
Debug mode (True/False) | No |
LOG_LEVEL |
Logging level (DEBUG/INFO/WARNING/ERROR) | No |
- Manual: Triggered manually via command line
- Scheduled: For use with cron jobs or task schedulers
- Webhook: For future webhook integration
Add to your crontab to run sync every hour:
0 * * * * cd /path/to/your/project && python manage.py sync_github_issues --sync-type scheduled
Create a scheduled task that runs:
C:\path\to\python.exe C:\path\to\your\project\manage.py sync_github_issues --sync-type scheduled
-
Authentication Errors:
- Verify your GitHub token has correct permissions
- Check that your Notion integration has access to the database
-
Rate Limit Issues:
- GitHub API has rate limits (5000 requests/hour for authenticated users)
- Use
--status
flag to check current rate limit
-
Notion Database Errors:
- Ensure your database has all required properties
- Verify the database ID is correct
- Check that the integration has write access
-
Sync Failures:
- Check logs in
automation.log
- Use Django admin to view detailed error messages
- Run with
LOG_LEVEL=DEBUG
for verbose output
- Check logs in
Enable debug logging:
LOG_LEVEL=DEBUG
DEBUG=True
Then run:
python manage.py sync_github_issues --status
The system uses GitHub REST API v3 to:
- Fetch assigned issues:
GET /issues?assignee={username}
- Get repository information
- Handle pagination automatically
- Respect rate limits
The system uses Notion API v1 to:
- Create database pages
- Update existing pages
- Query existing issues
- Handle rich text content
- Custom Fields: Modify
NotionService._build_page_properties()
to add new Notion properties - Filters: Update
GitHubService.get_assigned_issues()
to add issue filtering - Webhooks: Extend the automation service to handle GitHub webhooks
Run the Django development server:
python manage.py runserver
Test the sync manually:
python manage.py sync_github_issues --issue-id YOUR_ISSUE_ID
- Store sensitive tokens in environment variables, never in code
- Use HTTPS for production deployments
- Regularly rotate your GitHub and Notion tokens
- Review GitHub token permissions regularly
- Fork the repository
- Create a feature branch
- Make your changes
- Add tests if applicable
- Submit a pull request
This project is licensed under the MIT License - see the LICENSE file for details.
For issues and questions:
- Check the troubleshooting section
- Review the logs in
automation.log
- Create an issue in the GitHub repository