From 12728c71bd3f34ca888a1c36e676a84349891169 Mon Sep 17 00:00:00 2001 From: Mark Likhachev Date: Tue, 13 Sep 2022 13:28:11 +0300 Subject: [PATCH] =?UTF-8?q?=D0=9F=D0=BE=D0=B4=D0=B4=D0=B5=D1=80=D0=B6?= =?UTF-8?q?=D0=BA=D0=B0=20=D0=BF=D0=BE=D0=BB=D1=8C=D0=B7=D0=BE=D0=B2=D0=B0?= =?UTF-8?q?=D1=82=D0=B5=D0=BB=D1=8C=D1=81=D0=BA=D0=B8=D1=85=20=D0=BC=D0=B5?= =?UTF-8?q?=D1=82=D0=BE=D0=BA=20Github=20=D0=B2=20Notion?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- main.py | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/main.py b/main.py index ecaa01c..57365a6 100644 --- a/main.py +++ b/main.py @@ -29,6 +29,7 @@ ) GH_ASSIGNEES_TO_NOTION = json.loads(os.environ["GH_ASSIGNEES_TO_NOTION"]) +GH_LABELS_TO_NOTION = json.loads(os.environ["GH_LABELS_TO_NOTION"]) GH_STATUSES_TO_NOTION = json.loads(os.environ["GH_STATUSES_TO_NOTION"]) # Authentication @@ -107,7 +108,9 @@ def create_or_update_page( if issue_labels: payload["properties"][LABELS_PROPERTY_NAME] = { - "multi_select": [{"name": label["name"]} for label in issue_labels] + "multi_select": [ + {"name": GH_LABELS_TO_NOTION[label["name"]]} for label in issue_labels + ] } if not page: payload["properties"][STATUS_PROPERTY_NAME] = { @@ -145,10 +148,10 @@ def get_page(issue_number: str) -> dict: pages_amount = len(results) if pages_amount != 1: - raise ValueError( - f"Cannot find a specific page. Number of pages found: {pages_amount}. " + print(f"Cannot find a specific page. Number of pages found: {pages_amount}.") + if DEBUGGING: f"Urls are: {', '.join([page['url'] for page in results])}" - ) + raise ValueError("Cannot find a specific page.") else: return results[0] @@ -168,7 +171,9 @@ def update_labels(page: dict, labels: list) -> None: payload = { "properties": { LABELS_PROPERTY_NAME: { - "multi_select": [{"name": label["name"]} for label in labels] + "multi_select": [ + {"name": GH_LABELS_TO_NOTION[label["name"]]} for label in labels + ] }, }, }