Notion2Github - en

Notion2Github - ko

Automatic syncronization from Notion to Github


<aside> ⚠️ NOTE: Notion2Github is dependent on notion-py, the unofficial Notion API created by Jamie Alexandre. This may not be stable because it is not an official API. If you need to use in production, I recommend waiting for their official release.

</aside>


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.

    https://s3-us-west-2.amazonaws.com/secure.notion-static.com/1ab66564-6667-4b94-a7d7-6021dfa0bcd4/readme-image-0.png

    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/[email protected]
        with:
          database-url: '<https://www.notion.so/acc3dfd0339e4cacb5baae8673fddfad>'
          docs-directory: docs
        env:
          NOTION_TOKEN: ${{ secrets.NOTION_TOKEN }}

      - name: Format documents
        uses: creyD/[email protected]
        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/[email protected]
        with:
          database-url: '<https://www.notion.so/acc3dfd0339e4cacb5baae8673fddfad>'
          docs-directory: docs
        env:
          NOTION_TOKEN: ${{ secrets.NOTION_TOKEN }}

      - name: Format documents
        uses: creyD/[email protected]
        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

younho9/narkdown