Skip to content

litencatt/notion-db-auto-relator

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

notion-db-auto-relator

Create and update relation for Parent and Child DB in Notion automatically.

Usage

Setup in Notion

  1. Create a parent DB and a child DB that you want to relate automatically.
  2. Duplicate this settings DB.
  3. Create Notion API Integration.
  4. Invite the API Integration to settings DB, Parent DB and Child DB.

Run notion-db-auto-relator locally

$ git clone git@github.com:litencatt/notion-db-auto-relator.git
$ cd notion-db-auto-relator
$ yarn
$ NOTION_TOKEN=*** SETTINGS_DB_ID=*** yarn start

Run notion-db-auto-relator as GitHub Actions

settings example

on:
  workflow_dispatch:
  schedule:
    - cron: '00 * * * *'

jobs:
  run-job:
    name: run relation
    runs-on: ubuntu-latest
    env:
      TZ: Asia/Tokyo
      LANG: ja_JP.UTF-8
    steps:
      - uses: actions/checkout@v2
      - name: Relation
        uses: litencatt/notion-db-auto-relator@main
        env:
          NOTION_TOKEN: ${{ secrets.NOTION_TOKEN }}
          SETTINGS_DB_ID: ${{ secrets.SETTINGS_DB_ID }}

Settings DB examples and relation results

Settings DB set values like this,

image

Parent DB and Child DB example

image

Settings1 relation execute result

Settings1 ✅ and Run actions or NOTION_TOKEN=*** SETTINGS_DB_ID=*** yarn start

  • Relation property Relation-with-Name is created to ParentDB.
  • Related like ParentDB JOIN ChildDB ON ParentDB.Name = ChildDB.Name.
Before After
image image

Settings2 relation execute result

Settings2 ✅ and Run actions or NOTION_TOKEN=*** SETTINGS_DB_ID=*** yarn start

  • Relation property Relation with Tags is created to ParentDB.
  • Related like ParentDB JOIN ChildDB ON ParentDB.Tags = ChildDB.Tags.
Before After
image image

Settings3 relation execute result

Settings3 ✅ and Run actions or NOTION_TOKEN=*** SETTINGS_DB_ID=*** yarn start

  • Relation property Relation with Name,Tags is created to ParentDB.
  • Related like ParentDB JOIN ChildDB ON ParentDB.Name = ChildDB.Name AND ParentDB.Tags = ChildDB.Tags.
Before After
image image