This Danger plugin manages Notion pages automatically based on a Pull Request status.
First of all an Internal Integration Token is needed in order to manage the connection between GitHub and Notion. Follow the steps in this tutorial to generate one and store the token for later.
Now create a Notion page with a Status
status property and a Pull Request
url property. The most common scenario is a database of tasks where each task is a page with the described properties among others:
- Install the
danger-plugin-notion-tasks
plugin using your favourite package manager:
// Yarn
yarn add --dev @heritageholdings/danger-plugin-notion-tasks
// NPM
npm install -D @heritageholdings/danger-plugin-notion-tasks
- Add the following code to your
dangerfile
:
notionSync({
// This should be the user that owns the pages.
//
// For example:
// https://www.notion.so/this-is-the-username/Page-1069eef615114va810dfg797219147fb
// --------------------
notionUser: "notion-page-username",
// How the page's Status should be changed
// based on the Pull Request lifecycle.
prStatusMap: {
open: "In progress",
closed: "Done",
merged: "Done",
locked: "Done",
},
});
- Make the Danger bot run everytime a Pull Request changes:
on:
pull_request:
types:
- opened
- synchronize
- reopened
- edited
- closed
- In your GitHub repo add a new GitHub Secret
NOTION_TOKEN
with the token generated in the previous section from Notion.
Create a new Pull Request and add everywhere in the description:
Closes https://www.notion.so/this-is-the-username/Your-Notion-Page-1069eef615114va810dfg797219147fb
This Notion page will be recognized by the Danger bot and managed based on the PR status. For example, opening the PR will change the page Status to In progress
and merging it to Done
following the default configuration above. The PR link will be also added to the Pull Request
property.
In this case closes
(not case sensitive) is one of the default keywords used by this plugin to recognize a target Notion page. By default all the GitHub keywords are supported, but it's possible to change them through the triggerWords
setting.