-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgh_notion_sync.py
33 lines (24 loc) · 1000 Bytes
/
gh_notion_sync.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
import ghsettings
import os
import libs.ghhelper as ghhelper
import libs.notion_data as p
from libs.notion_data import NotionDatabase
from notion_client import Client
# Initialize Notion client.
notion = Client(auth=os.environ['NOTION_TOKEN'])
# Gather issues first so that we can populate select properties accordingly.
issues = ghhelper.get_all_issues()
labels = ghhelper.extract_labels(issues)
# Extract the milestones for relational purposes.
milestones_db = NotionDatabase(ghsettings.milestones_id, notion)
milestones = ghhelper.extract_milestones(milestones_db.get_all_pages())
# Add labels property limited to all known labels
properties = ghsettings.properties + [p.multi_select('Labels', labels)]
# Create database object.
notion_db = NotionDatabase(ghsettings.database_id, notion, properties)
# Set properties on database.
notion_db.update_props()
# Gather pages.
pages = notion_db.get_all_pages()
# Start sync.
ghhelper.sync_github_to_notion(issues, pages, milestones, notion_db)