Automatic syncronization from Notion to Github
⚠️ NOTE: Narkdown is dependent on notion-py, the unofficial Notion API created by Jamie Alexandre. It can not gurantee it will stay stable. If you need to use in production, I recommend waiting for their official release.
-
Go to
github.com/{your_id}/{your_repo}/settings/secrets/actions
-
Set
token_v2
of Notion to your repository secret. -
Create a workflow in
.github/workflows/**.yml
of your repository
Here are examples.
name: Notion2Github
on:
pull_request:
push:
branches:
- main
jobs:
auto-sync-from-notion-to-github:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Notion2Github
uses: younho9/notion2github@v1.1.0
with:
database-url: 'https://www.notion.so/acc3dfd0339e4cacb5baae8673fddfad'
docs-directory: docs
env:
NOTION_TOKEN: ${{ secrets.NOTION_TOKEN }}
- name: Format documents
uses: creyD/prettier_action@v3.1
with:
prettier_options: --write ./docs/**/*.md
commit_message: 'docs: Update docs (auto)'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
name: Notion2Github
on:
schedule:
- cron: '0 14 * * *'
jobs:
auto-sync-from-notion-to-github:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Notion2Github
uses: younho9/notion2github@v1.1.0
with:
database-url: 'https://www.notion.so/acc3dfd0339e4cacb5baae8673fddfad'
docs-directory: docs
env:
NOTION_TOKEN: ${{ secrets.NOTION_TOKEN }}
- name: Format documents
uses: creyD/prettier_action@v3.1
with:
prettier_options: --write ./docs/**/*.md
commit_message: 'docs: Update docs (auto)'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Here is an database template page for importing pages from the database. Move to that page, duplicate it, and test it.
Name | Description | Required | Default |
---|---|---|---|
database-url |
URL of the Notion database to extract. | required |
|
docs-directory |
Directory in which the Notion pages to extract will be stored. | "docs" |
|
filter-prop |
Property of the filter to apply to the notion database. | "" |
|
filter-value |
Value of the filter to apply to the notion database. | "" |
Narkdown provides some configuration for how to extract documents. You can configure Narkdown via narkdown.config.json
.
Create narkdown.config.json
in root directory of your repository.
For more information on configure your environment, see the document in Nakdown.
// narkdown.config.json
{
"exportConfig": {
"recursiveExport": true,
"createPageDirectory": true,
"addMetadata": true,
"appendCreatedTime": true,
"generateSlug": true
},
"databaseConfig": {
"categoryColumnName": "Category",
"statusColumnName": "Status",
"currentStatus": "✅ Completed",
"nextStatus": "🖨 Published"
}
}
Notion2Github is a step in the workflow, just import the contents of notion to a running virtual machine in github action.
There are great actions to commit the imported content to your repository.
MIT © younho9