-
Notifications
You must be signed in to change notification settings - Fork 0
78 lines (66 loc) · 2.18 KB
/
notion_to_github.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
name: Notion to Github Sync
on:
schedule:
- cron: '0 * * * *' # Runs every hour
workflow_dispatch:
permissions:
contents: write # Ensures write permissions for GITHUB_TOKEN
jobs:
fetch-notion-content:
runs-on: ubuntu-latest
steps:
# Step 1: Checkout repository
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0 # Ensures full history for pull/rebase
# Step 2: Setup Node.js
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
# Step 3: Install dependencies in 'project' directory
- name: Install dependencies
working-directory: ./project
run: npm install
# Step 4: Fetch Notion Content (Debugging Output)
- name: Fetch Notion Content
working-directory: ./project
env:
NOTION_API_KEY: ${{ secrets.NOTION_API_KEY }}
NOTION_PAGE_ID: ${{ secrets.NOTION_PAGE_ID }}
run: |
echo "Using API Key: ${NOTION_API_KEY:0:4}***"
echo "Using Page ID: ${NOTION_PAGE_ID}"
node notion-sync.js > notion-output.log
echo "Fetched Notion Content:"
cat notion-output.log
# Step 5: Configure Git
- name: Configure Git
run: |
git config user.name "github-actions"
git config user.email "[email protected]"
# Step 6: Pull Remote Changes Before Committing
- name: Pull Remote Changes
run: |
git fetch origin main
git pull --rebase origin main || true
# Step 7: Track Untracked Files and Debug Changes
- name: Track Changes and Debug
run: |
echo "Staging Files for Commit:"
git status
git add -A
git status
# Step 8: Force Commit and Push Changes
- name: Commit and Push Changes
run: |
git commit -m "Update: Fetched new Notion content" --allow-empty
git push origin main
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# Step 9: Final Debugging Output
- name: Confirm Push Success
run: |
echo "Latest commit:"
git log -1