Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion .github/workflows/md-to-notion.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
Expand All @@ -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
Expand All @@ -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: |
Expand Down
13 changes: 0 additions & 13 deletions docs/about/sbin.md

This file was deleted.

1 change: 0 additions & 1 deletion docs/about/테스트.md

This file was deleted.

13 changes: 0 additions & 13 deletions docs/about/테스트로-이름-수정.md

This file was deleted.

16 changes: 14 additions & 2 deletions scripts/md_to_notion.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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
Expand Down
Loading