Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Notion과 Github Issue 연동하는 워크플로우를 작성한다. #35

Draft
wants to merge 2 commits into
base: develop
Choose a base branch
from
Draft
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
74 changes: 74 additions & 0 deletions .github/workflows/notion-github-issue-sync.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
name: Sync GitHub Issues to Notion

on:
issues:
types: [opened, closed, reopened]

jobs:
sync-to-notion:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20'

- name: Create temp directory and install dependencies
run: |
mkdir temp
cd temp
echo '{"type": "module"}' > package.json
npm install @notionhq/client

- name: Create sync script
run: |
cat > temp/sync.js << 'EOF'
import { Client } from '@notionhq/client';

async function sync() {
const notion = new Client({ auth: process.env.NOTION_KEY });

try {
await notion.pages.create({
parent: {
database_id: process.env.NOTION_DATABASE_ID,
},
properties: {
이름: {
title: [
{
text: {
content: process.env.ISSUE_TITLE,
},
},
],
},
상태: {
select: {
name: process.env.ISSUE_STATE === 'open' ? '시작 전' : '완료',
},
},
},
});

console.log(`Issue "${process.env.ISSUE_TITLE}" 가 Notion에 성공적으로 동기화되었습니다.`);

} catch (error) {
console.error(`Notion 동기화 실패: ${error.message}`);
process.exit(1);
}
}

sync();
EOF

- name: Run sync script
env:
NOTION_KEY: ${{ secrets.NOTION_KEY }}
NOTION_DATABASE_ID: ${{ secrets.NOTION_DATABASE_ID }}
ISSUE_TITLE: ${{ github.event.issue.title }}
ISSUE_STATE: ${{ github.event.issue.state }}
run: node temp/sync.js