From 20d348a2fbf9f4e7678015010d9a9e1e74b42b20 Mon Sep 17 00:00:00 2001 From: server-cron Date: Wed, 27 May 2026 14:57:21 +0900 Subject: [PATCH 1/2] =?UTF-8?q?feat(sync):=20=EC=96=91=EB=B0=A9=ED=96=A5?= =?UTF-8?q?=20=EB=8F=99=EA=B8=B0=ED=99=94=20=EB=B3=B4=EC=99=84=203?= =?UTF-8?q?=EA=B0=80=EC=A7=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 순환 동기화 차단: server-cron 커밋 시 Actions 스킵 - 멀티 커밋 push 전체 범위 감지: GIT_BEFORE..GIT_AFTER - 수정 케이스 title 업데이트 반영 Co-Authored-By: Claude Sonnet 4.6 --- .github/workflows/md-to-notion.yml | 6 +++++- scripts/md_to_notion.py | 16 ++++++++++++++-- 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/.github/workflows/md-to-notion.yml b/.github/workflows/md-to-notion.yml index 9e6033e..84097ce 100644 --- a/.github/workflows/md-to-notion.yml +++ b/.github/workflows/md-to-notion.yml @@ -12,6 +12,7 @@ permissions: jobs: sync: runs-on: ubuntu-latest + if: github.event.head_commit.author.name != 'server-cron' env: NOTION_TOKEN: ${{ secrets.NOTION_TOKEN }} NOTION_ABOUT: ${{ secrets.NOTION_ABOUT }} @@ -27,7 +28,7 @@ jobs: - name: Checkout uses: actions/checkout@v4 with: - fetch-depth: 2 + fetch-depth: 0 - name: Set up Python uses: actions/setup-python@v5 @@ -39,6 +40,9 @@ jobs: - name: Sync docs to Notion run: python3 scripts/md_to_notion.py + env: + GIT_BEFORE: ${{ github.event.before }} + GIT_AFTER: ${{ github.sha }} - name: Commit updated sync maps run: | diff --git a/scripts/md_to_notion.py b/scripts/md_to_notion.py index e00027d..22ee7d7 100644 --- a/scripts/md_to_notion.py +++ b/scripts/md_to_notion.py @@ -269,6 +269,12 @@ def get_page_last_edited(page_id: str) -> str: return r.json().get("last_edited_time", "") +def update_page_title(page_id: str, title: str): + _api("patch", f"/pages/{page_id}", json={ + "properties": {"제목": {"title": [{"text": {"content": title}}]}} + }) + + def update_page_content(page_id: str, blocks: list): """기존 블록 전체 삭제 후 새 블록 추가.""" for bid in get_child_block_ids(page_id): @@ -324,10 +330,14 @@ def file_to_page_id(sync_map: dict, filepath: str) -> str | None: def get_changed_files(section_dir: str) -> dict[str, list[str]]: result = {"modified": [], "added": [], "deleted": []} + before = os.environ.get("GIT_BEFORE", "") + after = os.environ.get("GIT_AFTER", "HEAD") + if not before or before == "0" * 40: + before = "HEAD~1" try: out = subprocess.check_output( ["git", "-c", "core.quotepath=false", "diff", "--name-status", - "HEAD~1", "HEAD", "--", section_dir], + before, after, "--", section_dir], cwd=REPO_DIR, text=True, ) except subprocess.CalledProcessError: @@ -372,9 +382,11 @@ def process_section(section_dir: str): log(f" [수정] {filepath} → sync_map 미등록, 스킵") continue text = (REPO_DIR / filepath).read_text(encoding="utf-8") - _, body = parse_frontmatter(text) + fm, body = parse_frontmatter(text) + title = fm.get("title", Path(filepath).stem) blocks = md_body_to_blocks(body) log(f" [수정] {filepath} → {len(blocks)}개 블록 업로드 중...") + update_page_title(page_id, title) update_page_content(page_id, blocks) sync_map[page_id]["last_edited"] = get_page_last_edited(page_id) sync_dirty = True From dc0f9b0ca496448519f17dca6036befee278a17f Mon Sep 17 00:00:00 2001 From: server-cron Date: Wed, 27 May 2026 15:00:10 +0900 Subject: [PATCH 2/2] =?UTF-8?q?chore:=20=ED=85=8C=EC=8A=A4=ED=8A=B8=20?= =?UTF-8?q?=ED=8C=8C=EC=9D=BC=20=EC=A0=9C=EA=B1=B0=20(docs/about)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/about/sbin.md | 13 ------------- .../about/\355\205\214\354\212\244\355\212\270.md" | 1 - ...235\264\353\246\204-\354\210\230\354\240\225.md" | 13 ------------- 3 files changed, 27 deletions(-) delete mode 100644 docs/about/sbin.md delete mode 100644 "docs/about/\355\205\214\354\212\244\355\212\270.md" delete mode 100644 "docs/about/\355\205\214\354\212\244\355\212\270\353\241\234-\354\235\264\353\246\204-\354\210\230\354\240\225.md" diff --git a/docs/about/sbin.md b/docs/about/sbin.md deleted file mode 100644 index 8fe3a1f..0000000 --- a/docs/about/sbin.md +++ /dev/null @@ -1,13 +0,0 @@ ---- -id: 테스트로-이름-수정 -title: "sbin" -sidebar_position: 1 -slug: "1" ---- - -sbin 이 2026-05-27 14:19 에 수정 - -## 내용 수정 테스트 - -이 내용이 Notion에 반영되면 수정 케이스 동작 확인. - diff --git "a/docs/about/\355\205\214\354\212\244\355\212\270.md" "b/docs/about/\355\205\214\354\212\244\355\212\270.md" deleted file mode 100644 index 8c71250..0000000 --- "a/docs/about/\355\205\214\354\212\244\355\212\270.md" +++ /dev/null @@ -1 +0,0 @@ -dazc \ No newline at end of file diff --git "a/docs/about/\355\205\214\354\212\244\355\212\270\353\241\234-\354\235\264\353\246\204-\354\210\230\354\240\225.md" "b/docs/about/\355\205\214\354\212\244\355\212\270\353\241\234-\354\235\264\353\246\204-\354\210\230\354\240\225.md" deleted file mode 100644 index 0551e43..0000000 --- "a/docs/about/\355\205\214\354\212\244\355\212\270\353\241\234-\354\235\264\353\246\204-\354\210\230\354\240\225.md" +++ /dev/null @@ -1,13 +0,0 @@ ---- -id: 테스트로-이름-수정 -title: "테스트로 이름 수정" -sidebar_position: 1 -slug: "1" ---- - -수정 - -
- -테스트 수정 2026. 05. 26. (화) 16:40:11 KST -