forked from richartkeil/notion-guardian
-
Notifications
You must be signed in to change notification settings - Fork 0
49 lines (44 loc) · 1.34 KB
/
backup.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
name: "Backup Notion Workspace"
on:
push:
branches:
- main
schedule:
- cron: "0 0 * * *"
jobs:
backup:
runs-on: ubuntu-latest
name: Backup
timeout-minutes: 15
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v3
with:
node-version: '20'
- name: Run backup script
run: npm install && npm run backup
env:
NOTION_TOKEN: ${{ secrets.NOTION_TOKEN }}
NOTION_SPACE_ID: ${{ secrets.NOTION_SPACE_ID }}
NOTION_USER_ID: ${{ secrets.NOTION_USER_ID }}
- name: Checkout backup repo
uses: actions/checkout@v4
with:
repository: ${{ secrets.REPO_USERNAME }}/${{ secrets.REPO_NAME }}
token: ${{ secrets.REPO_PERSONAL_ACCESS_TOKEN }}
path: "backup-repo"
- name: Commit changes to backup repo
env:
REPO_EMAIL: ${{ secrets.REPO_EMAIL }}
REPO_USERNAME: ${{ secrets.REPO_USERNAME }}
run: |
cp -a workspace/. backup-repo/
cd backup-repo
git config --local user.email "${REPO_EMAIL}"
git config --local user.name "${REPO_USERNAME}"
git add .
if [ -z "$(git status --porcelain)" ]; then
exit 0
fi
git commit -m "Automated Notion workspace backup"
git push