Skip to content

Commit 811310a

Browse files
authored
Add Notion sync workflow to GitHub Actions
This workflow synchronizes data from Notion to a GitHub branch every hour and allows for manual triggering. It includes steps for checking out the repository, setting up Node.js, installing dependencies, running the Notion sync script, committing changes, and creating a pull request.
1 parent 091c337 commit 811310a

1 file changed

Lines changed: 52 additions & 0 deletions

File tree

.github/workflows/notion-sync.yml

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
name: Notion to GitHub Branch
2+
3+
# Run every hour or manually
4+
on:
5+
schedule:
6+
- cron: '0 * * * *' # every hour
7+
workflow_dispatch: # allows manual trigger
8+
9+
jobs:
10+
sync:
11+
runs-on: ubuntu-latest
12+
13+
steps:
14+
# Step 1: Checkout repo
15+
- name: Checkout repository
16+
uses: actions/checkout@v3
17+
18+
# Step 2: Setup Node.js
19+
- name: Setup Node.js
20+
uses: actions/setup-node@v3
21+
with:
22+
node-version: '20'
23+
24+
# Step 3: Install dependencies
25+
- name: Install dependencies
26+
run: npm install
27+
28+
# Step 4: Run the Notion sync script
29+
- name: Run Notion sync
30+
run: node sync_notion.js
31+
env:
32+
NOTION_TOKEN: ${{ secrets.NOTION_TOKEN }}
33+
34+
# Step 5: Commit and push to notion-to-github branch
35+
- name: Commit and push to branch
36+
run: |
37+
git config user.name "GitHub Actions"
38+
git config user.email "actions@github.com"
39+
git checkout -B notion-to-github
40+
git add .
41+
git diff --quiet && git diff --staged --quiet || git commit -m "Sync from Notion $(date +%Y-%m-%d)"
42+
git push -f origin notion-to-github
43+
44+
# Step 6: Create Pull Request
45+
- name: Create Pull Request
46+
uses: peter-evans/create-pull-request@v5
47+
with:
48+
token: ${{ secrets.GITHUB_TOKEN }}
49+
branch: notion-to-github
50+
base: main
51+
title: "Sync from Notion"
52+
body: "Automated sync from Notion workspace"

0 commit comments

Comments
 (0)