Skip to content

Notion to GitHub Branch #3

Notion to GitHub Branch

Notion to GitHub Branch #3

Workflow file for this run

name: Notion to GitHub Branch
# Run every hour or manually
on:
schedule:
- cron: '0 * * * *' # every hour
workflow_dispatch: # allows manual trigger
jobs:
sync:
runs-on: ubuntu-latest
permissions:
contents: write
pull-requests: write
steps:
# Step 1: Checkout repo
- name: Checkout repository
uses: actions/checkout@v3
# Step 2: Setup Node.js
- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: '20'
# Step 3: Install dependencies
- name: Install dependencies
run: npm install
# Step 4: Run the Notion sync script
- name: Run Notion sync
run: node sync_notion.js
env:
NOTION_TOKEN: ${{ secrets.NOTION_TOKEN }}
# Step 5: Commit and push to notion-to-github branch
- name: Commit and push to branch
run: |
git config user.name "GitHub Actions"
git config user.email "actions@github.com"
git checkout -B notion-to-github
git add .
git diff --quiet && git diff --staged --quiet || git commit -m "Sync from Notion $(date +%Y-%m-%d)"
git push -f origin notion-to-github
# Step 6: Create Pull Request
- name: Create Pull Request
uses: peter-evans/create-pull-request@v5
with:
token: ${{ secrets.GITHUB_TOKEN }}
branch: notion-to-github
base: main
title: "Sync from Notion"
body: "Automated sync from Notion workspace"