How to compile Latex with Github Actions



  • I'm not sure if this is the right place to ask this but I'm basically using git and github for version control for writing my thesis. My idea was to have a github action that compiles the code whenever I push to the main branch and then uploads the pdf. To do so, I have this workflow:

    name: "Build PDF"
    

    on:
    push:
    branches: [ main ]
    pull_request:
    branches: [ main ]

    jobs:
    build:
    runs-on: ubuntu-latest
    container:
    image: ghcr.io/moderncv/debian-texlive-docker:main
    steps:
    - name: Checkout code
    uses: actions/checkout@v3
    - name: Build PDF
    run: latexmk ./thesis.tex
    - name: Upload PDF
    uses: actions/upload-artifact@v3
    with:
    name: thesis.pdf
    path: ./thesis.pdf

    This is sort of working. The step that compiles the code is working, but the pdf does not show up on the repository, so I'm assuming that the upload step does not work. How can I fix this?



  • Uploading an artifact lets it be accessed by a future github action run. It doesn’t commit and push the file to the repo.

    See the docs for how to manually retrieve artifacts: https://docs.github.com/en/actions/managing-workflow-runs/downloading-workflow-artifacts

    You might want to look into services like ReadTheDocs or github pages, as potential places to automatically publish the output from your latex build. E.g., https://docs.github.com/en/pages/getting-started-with-github-pages/configuring-a-publishing-source-for-your-github-pages-site .



Suggested Topics

  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2