Skip to content
This repository has been archived by the owner on Nov 14, 2021. It is now read-only.

narkdown/notion2github

Use this GitHub action with your project
Add this Action to an existing workflow or create a new one
View on Marketplace

Repository files navigation

Notion2Github

Notion2Github

GitHub Action: View on Marketplace Demo: available Version: v1.0.1 license: MIT

| English | 한국어 |

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.


Usage

Quick Start

  1. Go to github.com/{your_id}/{your_repo}/settings/secrets/actions

  2. Set token_v2 of Notion to your repository secret.

    notion2github-image-0

    How To Find Your Notion v2 Token - Red Gregory

    Encrypted secrets

  3. Create a workflow in .github/workflows/**.yml of your repository

Here are examples.

Example Workflow

Example 1 (run on push & pull request in main)

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 }}

Example 2 (scheduled)

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 }}

Useful site for crontab setting

Live examples

Database template page for test

Here is an database template page for importing pages from the database. Move to that page, duplicate it, and test it.

notion2github-image-1

Configuration

Parameters

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. ""

Configuring Narkdown

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"
  }
}

Used in combination with other actions

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.

License

MIT © younho9