Skip to content

Instantly share code, notes, and snippets.

@dgerosa
Last active May 6, 2023 11:36
Show Gist options
  • Star 9 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save dgerosa/2e1f47a39180f39bde848e38243efa94 to your computer and use it in GitHub Desktop.
Save dgerosa/2e1f47a39180f39bde848e38243efa94 to your computer and use it in GitHub Desktop.
Github workflow to compile and deploy latex
# Github workflow to compile latex and deploy the pdf to an orphan branch.
# The latest compiled pdf is at available at e.g.
# https://github.com/dgerosa/reponame/blob/build/filename.pdf
# Davide Gerosa (2021) https://github.com/dgerosa
name: writeapaper
on: [push]
jobs:
paper:
runs-on: ubuntu-latest
env:
# Edit here with the names of your latex file and directory (can use ".")
DIR: draft
FILE: draft
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Install TeXlive
run: sudo apt-get update && 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 }}
run: pdflatex ${{ env.FILE }}; bibtex ${{ env.FILE }}; pdflatex ${{ env.FILE }}; pdflatex ${{ 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
with:
name: ${{ env.FILE }}.pdf
path: ./github_artifacts
deploy:
# Edit here if compiling multiple papers
needs: [paper]
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
- uses: actions/download-artifact@v2
with:
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
with:
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