58 lines (51 loc) Β· 1.86 KB
/
main.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
name: "Roam Research backup"
on:
push:
branches:
- main
schedule:
# Here you can change how often your backup runs. See https://crontab.guru/examples.html
- cron: "0 * * * *"
jobs:
backup:
runs-on: ubuntu-latest
name: Backup
steps:
- uses: actions/checkout@v2
with:
repository: ${{ secrets.BACKUP_REPO }}
token: ${{ secrets.ACCESS_TOKEN }}
- name: Setup Node
uses: actions/setup-node@v2
with:
node-version: '14'
- name: Set up Python 3.8
uses: actions/setup-python@v1
with:
python-version: 3.8
- name: Setup dependencies
run: |
pip install requests
- name: Run Backup
run: |
cd /tmp
git clone -q https://github.com/everruler12/roam2github.git roam2github
cd $_
npm i
npm run backup -s
cd /home/runner/work/roam2github-actions/roam2github-actions
curl https://raw.githubusercontent.com/JimmyLv/roam2github-actions/main/scripts/roam_image_backup.py -o roam_image_backup.py
mkdir -p ./markdown/${{ secrets.ROAM_GRAPH }}/images
python roam_image_backup.py json/${{ secrets.ROAM_GRAPH }}.json ./markdown/${{ secrets.ROAM_GRAPH }}/images
sed -i 's/- #/\n#/g;s/](</](/g;s/.md>)/.md)/g;s/- \([[:digit:]]*\)\./\n\1\./g;s~(https.*%2F\(.*\)\?alt=media.*)~(./images\/\1)~g' ./markdown/${{ secrets.ROAM_GRAPH }}/*.md
env:
ROAM_EMAIL: ${{ secrets.ROAM_EMAIL }}
ROAM_PASSWORD: ${{ secrets.ROAM_PASSWORD }}
ROAM_GRAPH: ${{ secrets.ROAM_GRAPH }}
BACKUP_EDN: true
BACKUP_JSON: true
BACKUP_MARKDOWN: true
- name: Commit Changes
uses: everruler12/git-auto-commit-action@latest
with:
commit_message: Automatic backup