Skip to content

Sync overleaf

Sync overleaf #10

Workflow file for this run

on:
# schedule:
# - cron: "*/5 * * * *"
workflow_dispatch:
permissions:
contents: write
pull-requests: write
issues: write
name: "Sync overleaf"
jobs:
sync:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
ref: sync_overleaf
fetch-depth: '0'
- name: Sync overleaf
id: sync_overleaf
run: |
git remote add overleaf https://git:${OVERLEAF_TOKEN}@git.overleaf.com/65df171af9ff7989580f017d
git remote add origin_token https://git:${GITHUB_TOKEN}@github.com/columnflow/demo_docs.git
git fetch overleaf
git pull overleaf master
git push origin_token HEAD:sync_overleaf
commitDiffCount=$(git diff origin_token/sync_overleaf origin_token/master | wc -l)
echo "$foo" >> $GITHUB_OUTPUT
env:
OVERLEAF_TOKEN: ${{ secrets.OVERLEAF_TOKEN }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: check for existing PRs
id: check_for_existing_PRs
if: steps.sync_overleaf.outputs.commitDiffCount > 0
run: |
prs=$(gh pr list \
--repo "$GITHUB_REPOSITORY" \
--head 'sync_overleaf' \
--base 'master' \
--json 'Merge sync_overleaf into master' \
--jq 'length')
if ((prs > 0)); then
echo "skip=true" >> "$GITHUB_OUTPUT"
fi
- name: create pull request
if: ((steps.sync_overleaf.outputs.commitDiffCount > 0) && (steps.check_for_existing_PRs.outputs.skip != 'true'))
run: gh pr create -B master -H sync_overleaf --title 'Merge sync_overleaf into master' --body 'Created by Github action'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}