This bot syncs public Notion pages as GitHub Discussions/Issues. It's done periodically, based on the pages shared with the Notion Integration, and based on metadata specific on your Notion page.
To use this tool, please make sure to have the following:
- Deploy this tool or run it locally with the relevant env vars.
- Make sure to add the user your wish to use as collaborator in your repos (this is needed only in order to delete Discussions)
- To make a Notion page public and syncable, first make sure to share this page with the Notion Integration you created:
- If you wish to make the Notion page public (with the Notion url), also tick
Share to web
:
- Annotate the top of your Notion page with the repo you wish to sync the page with the following text (NOT as code block, just as text - this should be the first block of your Notion page):
/github-public dotansimha/test-notion-sync discussion
You can also specify a custom GitHub Discussion category (the default is General):
/github-public dotansimha/test-notion-sync discussion General
Or, as an issue:
You can also specify a custom GitHub Discussion category (the default is General):
/github-public dotansimha/test-notion-sync issue
You can find a synced example page here: dotansimha/test-notion-sync#12
To remove a public discussion:
- Make sure to delete the annotation from your page.
- Wait for the next sync (or, manually run it)
- You can also remove now the integration access from the page.
- Clone this repo
- Make sure to install Wrangler CLI: https://developers.cloudflare.com/workers/wrangler/get-started/ and use
pnpm
- Create a Notion integration and get your Notion token (see https://www.notion.so/my-integrations). Use the token as
NOTION_TOKEN
env var. - Create a GitHub Personal Access token for the relevant user (to create/update/delete the GH Discussions). Use the token as
GH_BOT_TOKEN
env var. - Create
.dev.vars
file and addNOTION_TOKEN
andGH_BOT_TOKEN
to it (and other env vars if needed, see below) - Run
pnpm generate
to generate TypeScript types for the GraphQL queries. - Run
pnpm install
- Run
pnpm start
for development.
We use Wrangler for the Worker development.
The following configurations can be set in the env of your project, in order to customize how the bot will run:
NOTION_TOKEN
- required, a Notion intergraion API keyGH_BOT_TOKEN
- requried (also during development)DRY_RUN
- set to1
if you wish to just test the create/update/delete plan of this bot, without affecting any data on GitHub.ENABLE_FETCH
- Set to1
to enable. This will enable thefetch
event for the worker, this is helpful for development if you want to trigger the bot manually, or if you wish your bot to have a manual trigger.CUSTOM_HEADER_LINK
- customize the link added to the header of every GitHub issue/discussion. To use an external like, you can add markdown, for example:[The Guild's](https://the-guild.dev)
.IGNORED_REPOS
- If the GitHub user you are using, is used for creating other issues/discussions, or a real (non-bot) user, you can reduce the stress of loading existing issues/discussion with ignoring some repos. This field is comma-separated (for example:user/repo1,user/repo2
)
For local development, please add your config to a file called .dev.vars
- Every change to
main
branch will run CI and deploy to prod. - Make sure to configure your
NOTION_TOKEN
andGH_BOT_TOKEN
(PAT) as part of the env vars. - You can also deploy from local env by running:
pnpm run deploy
If you wish to have a clone of your own, make sure to rename worker name in the
wrangler.toml
file