This Notion integration updates Notion tasks when a linked Github PR is closed/merged. This integration requires the Notion task link be mentioned in the PR description. This example will guide you through setting up a Notion database, creating a Notion integration and sharing the database with the integration.
# Clone this repository locally
git clone https://github.com/makenotion/notion-sdk-js.git
# Switch into this project
cd notion-sdk-js/examples/notion-task-github-pr-sync
# Install the dependencies
npm install
In order for this Integration to work with Github, you'll need a Github Personal Access Token. You can create your GitHub Personal Access token by following the guide here. Make a note of the Personal Access token, we'll need it later.
If you don't have a Github Repository you may click here to set one up.
Once you've created a repository or if you already have one, make a note of the repository owner and repository name, we'll need it later.
You may skip this step if you have a Notion database to use with this integration.
If you don't have a Notion database, you may duplicate this empty database template, to get started.
If you'd like this Integration to also update a Database Status property, you should create one now.
If you already have one, make note of the Status Property Name, we'll need it later.
You may choose whether or not to update the Status Property by setting
UPDATE_STATUS_IN_NOTION_DB = <true|false>
in your .env file to true or false. More on this later.
In order to leverage the Notion API, we must first create an integration. To do that, click here, and click Create new integration.
As you progress through the fields, pay close attention to enabling the following permissions:
Capabilities > Content Capabilities > Read Content, Update Content, Insert Content. Capabilities > Comment Capabilities > Read Comments, Insert Comments
These capabilities are required to write comments on your Notion Tasks.
Once your integration is created, make a note of your Internal Integration Token, this will be your Notion API Key, we'll need it in the next step.
- Go to the database page in your workspace.
- Click the ••• on the top right corner of the page.
- At the bottom of the pop-up, click Add connections.
- Search for and select your integration in the Search for connections... menu.
Using the information you noted above, create a .env
file.
GITHUB_KEY=<your-github-personal-access-token>
NOTION_KEY=<your-notion-api-key>
GITHUB_REPO_OWNER=<github-owner-username>
GITHUB_REPO_NAME=<github-repo-name>
UPDATE_STATUS_IN_NOTION_DB = <true|false>
STATUS_PROPERTY_NAME = <your-status-property-name>
node index.js