-
Notifications
You must be signed in to change notification settings - Fork 0
78 lines (74 loc) · 2.65 KB
/
notion-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
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
# This is a basic workflow to help you get started with Actions
name: notion-backup
# Controls when the action will run.
# on:
# # Triggers the workflow on push or pull request events but only for the main branch
# push:
# branches: [main]
# pull_request:
# branches: [main]
on:
schedule:
- cron: "0 */12 * * *"
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
# This workflow contains a single job called "build"
build:
# The type of runner that the job will run on
runs-on: ubuntu-latest
# Steps represent a sequence of tasks that will be executed as part of the job
steps:
- uses: actions/checkout@v4
- uses: actions/[email protected]
with:
python-version: "3.10"
- name: install dependency
run: pip3 install requests
- name: run notion_backup.py
env:
NOTION_TOKEN: ${{ secrets.NOTION_TOKEN }} # 在后台配置好token,或者用NOTION_EMAIL和NOTION_PASSWORD也可以
run: |
echo '开始执行'
pwd
echo '执行前 ls'
ls
python notion_backup.py
echo '执行后 ls'
ls
echo '进入 backup 文件夹'
cd backup
pwd
echo 'backup 文件'
ls
echo 'backup 大小'
du -sh
echo '执行完成'
- name: rclone-install
run: |
# 安装 rclone
curl -O https://downloads.rclone.org/rclone-current-linux-amd64.zip
unzip rclone-current-linux-amd64.zip
cd rclone-*-linux-amd64
sudo mv rclone /usr/bin
sudo chmod +x /usr/bin/rclone
- name: rclone-config
env:
RCLONE_CONFIG: ${{ secrets.RCLONE }}
run: |
# 写配置文件
mkdir -p ~/.config/rclone/
cat << EOF > ~/.config/rclone/rclone.conf
$RCLONE_CONFIG
EOF
- name: rclone-run
run: |
# Rclone-Run
# 更改时区
sudo cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
echo "==========开始同步==========="
rclone sync /home/runner/work/notion-backup/notion-backup/backup dropbox:backup/notion -vv
rclone sync /home/runner/work/notion-backup/notion-backup/backup onedrive:backup/notion -vv
rclone size onedrive:backup/notion
curl -s -X POST https://api.telegram.org/bot'${{ secrets.TELEGRAM_BOT_TOKEN }}'/sendMessage -d chat_id='${{ secrets.TELEGRAM_CHAT_ID }}' -d text="github notion-backup 任务执行结束"