Skip to content

chore(authors): kane(윤성재) 추가 + /about 팀 섹션 반영 #22

chore(authors): kane(윤성재) 추가 + /about 팀 섹션 반영

chore(authors): kane(윤성재) 추가 + /about 팀 섹션 반영 #22

name: Notion → Published on PR Merge
on:
pull_request:
types: [closed]
branches: [main]
permissions:
contents: write
pull-requests: read
jobs:
update-notion:
if: github.event.pull_request.merged == true && startsWith(github.event.pull_request.head.ref, 'blog/')
runs-on: ubuntu-latest
steps:
- name: Extract Notion page ID from PR body or branch
id: extract
env:
PR_BODY: ${{ github.event.pull_request.body }}
BRANCH: ${{ github.event.pull_request.head.ref }}
run: |
# Try to extract page ID from PR body (notion_page_id: xxx)
PAGE_ID=$(echo "$PR_BODY" | grep -oP 'notion_page_id:\s*\K[a-f0-9-]+' || true)
if [ -z "$PAGE_ID" ]; then
echo "No page ID found in PR body, skipping"
echo "found=false" >> "$GITHUB_OUTPUT"
else
echo "page_id=$PAGE_ID" >> "$GITHUB_OUTPUT"
echo "found=true" >> "$GITHUB_OUTPUT"
fi
- name: Update Notion status to Published
if: steps.extract.outputs.found == 'true'
env:
NOTION_API_KEY: ${{ secrets.NOTION_API_KEY }}
PAGE_ID: ${{ steps.extract.outputs.page_id }}
run: |
curl -s -X PATCH "https://api.notion.com/v1/pages/${PAGE_ID}" \
-H "Authorization: Bearer ${NOTION_API_KEY}" \
-H "Notion-Version: 2022-06-28" \
-H "Content-Type: application/json" \
-d '{"properties":{"Status":{"status":{"name":"Published"}}}}'
echo "Notion status updated to Published: ${PAGE_ID}"
- name: Delete merged head branch
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
BRANCH: ${{ github.event.pull_request.head.ref }}
REPO: ${{ github.repository }}
run: |
echo "Deleting merged branch: ${BRANCH}"
gh api -X DELETE "repos/${REPO}/git/refs/heads/${BRANCH}" \
&& echo "Branch deleted: ${BRANCH}" \
|| echo "Branch delete skipped (already removed or protected): ${BRANCH}"