Skip to content

Instantly share code, notes, and snippets.

Forked from dgerosa/writeapaper.yml
Created December 17, 2021 20:31
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
What would you like to do?
Github workflow to compile and deploy latex
# Github workflow to compile latex and deploy the pdf to an orphan branch.
# Davide Gerosa (2021)
# Edit the DIR and FILE variables with the location of the latex file.
# Place the yml file in a directory called .github/workflows
# The latest compiled pdf is made available at e.g.
# You can also add a badge to your README:
# [![compile_deploy_latex]([repositoryname]/actions/workflows/compile_deploy_latex.yml/badge.svg)]([repositoryname]/actions)
# To compile multiple papers, duplicate the job called "paper" with different FILE/DIR names and add the "needs" line in the "deploy" job accordingly
name: compile_deploy_latex
on: [push]
runs-on: ubuntu-latest
# Edit here with the names of your latex file and directory (can use ".")
DIR: draft
FILE: main
- name: Checkout
uses: actions/checkout@v2
- name: Install TeXlive
run: sudo apt-get install texlive texlive-publishers texlive-science latexmk cm-super
- name: LaTeX compile
working-directory: ${{ env.DIR }}
run: latexmk -pdf -bibtex ${{ env.FILE }}
- name: move
run: mkdir -p github_artifacts && mv ${{ env.DIR }}/${{ env.FILE }}.pdf ./github_artifacts/
- name: Upload pdf as artifact
uses: actions/upload-artifact@v2
name: ${{ env.FILE }}.pdf
path: ./github_artifacts
# Edit here if compiling multiple papers
needs: [paper]
runs-on: ubuntu-latest
- name: Checkout
uses: actions/checkout@v2
- uses: actions/download-artifact@v2
path: github_artifacts
- name: move
run: mkdir -p github_deploy && mv github_artifacts/*/* github_deploy
- name: deploy on orphan branch
uses: peaceiris/actions-gh-pages@v3
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./github_deploy
publish_branch: build
force_orphan: true
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment