Skip to content

Instantly share code, notes, and snippets.

@habara-k
Last active December 30, 2024 13:55
Show Gist options
  • Save habara-k/3bea9e4defd4b56539bdacd22a1e8046 to your computer and use it in GitHub Desktop.
Save habara-k/3bea9e4defd4b56539bdacd22a1e8046 to your computer and use it in GitHub Desktop.

Overleafのバックアップを自動で取るためのメモ(無料)

How To

  1. Overleafでプロジェクトを立ち上げる.

  2. GitHubで(プライベート)リポジトリを作る

  3. 作ったリポジトリを以下のような構成にする.

.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 }}
  1. 作ったリポジトリのSettings -> Secrets から以下のAction secrets を追加する.
  • PROJECT_ID: 1. で作ったプロジェクトのID (プロジェクトを開いたときのURL https://www.overleaf.com/project/{id}{id}の部分)
  • EMAIL: Overleafに登録しているメールアドレス
  • PASSWORD: Overleafに登録しているパスワード

設定完了. 大体1時間おきに自動でバックアップが取られ, 変更があった場合はリポジトリのproject以下にpushされる.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment