-
Overleafでプロジェクトを立ち上げる.
-
GitHubで(プライベート)リポジトリを作る
-
作ったリポジトリを以下のような構成にする.
.github
└── workflows
└── backup.yml
# backup.yml
name: backup
on:
schedule:
- cron: '0 * * * *'
workflow_dispatch:
jobs:
backup:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
persist-credentials: false
fetch-depth: 0
- name: Setup Python
uses: actions/setup-python@v2
- name: Install dependencies
run: |
pip install requests bs4
git clone https://github.com/tobiasBora/overleafv2-git-integration-unofficial.git
cd overleafv2-git-integration-unofficial
chmod +x install.sh
./install.sh $GITHUB_WORKSPACE
- name: Backup project
run: |
git config --local user.name 'Github'
git config --local user.email '[email protected]'
mkdir -p project && cd project
$GITHUB_WORKSPACE/overleafv2-git https://www.overleaf.com/project/${{ secrets.PROJECT_ID }} --email=${{ secrets.EMAIL }} --password=${{ secrets.PASSWORD }}
- name: Push changes
uses: ad-m/github-push-action@master
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
branch: ${{ github.ref }}
- 作ったリポジトリのSettings -> Secrets から以下のAction secrets を追加する.
PROJECT_ID
: 1. で作ったプロジェクトのID (プロジェクトを開いたときのURLhttps://www.overleaf.com/project/{id}
の{id}
の部分)EMAIL
: Overleafに登録しているメールアドレスPASSWORD
: Overleafに登録しているパスワード
設定完了. 大体1時間おきに自動でバックアップが取られ, 変更があった場合はリポジトリのproject
以下にpushされる.