├── .dockerignore ├── .github ├── dependabot.yml └── workflows │ └── test.yml ├── .vscode └── ltex.dictionary.en-US.txt ├── CHANGELOG.md ├── Dockerfile ├── LICENSE ├── README.md ├── action.yml ├── entrypoint.sh └── test ├── biblatex.tex ├── math.tex ├── minted.tex ├── ref.bib └── test.tex /.dockerignore: -------------------------------------------------------------------------------- 1 | /.git* 2 | /action.yml 3 | /test/ 4 | -------------------------------------------------------------------------------- /.github/dependabot.yml: -------------------------------------------------------------------------------- 1 | version: 2 2 | updates: 3 | - package-ecosystem: "github-actions" 4 | directory: "/" 5 | schedule: 6 | interval: "weekly" 7 | -------------------------------------------------------------------------------- /.github/workflows/test.yml: -------------------------------------------------------------------------------- 1 | name: Test Github Action 2 | 3 | on: 4 | push: 5 | schedule: 6 | - cron: '0 0 1 * *' 7 | 8 | concurrency: 9 | group: ${{ github.workflow }}-${{ github.ref }} 10 | cancel-in-progress: true 11 | 12 | jobs: 13 | test: 14 | runs-on: ubuntu-latest 15 | steps: 16 | - uses: actions/checkout@v4 17 | - name: Compile basic LaTeX document 18 | uses: ./ 19 | with: 20 | root_file: test.tex 21 | working_directory: test/ 22 | - name: Compile basic LaTeX document with lualatex 23 | uses: ./ 24 | with: 25 | root_file: test.tex 26 | working_directory: test/ 27 | compiler: lualatex 28 | args: -file-line-error -interaction=nonstopmode 29 | - name: Compile LaTeX document with math symbols 30 | uses: ./ 31 | with: 32 | root_file: math.tex 33 | working_directory: test/ 34 | - name: Compile LaTeX document with biblatex/biber 35 | uses: ./ 36 | with: 37 | root_file: biblatex.tex 38 | working_directory: test/ 39 | - name: Compile LaTeX document with minted 40 | uses: ./ 41 | with: 42 | root_file: minted.tex 43 | working_directory: test/ 44 | extra_system_packages: python3-pygments 45 | args: "-pdf -latexoption=-shell-escape -latexoption=-file-line-error -latexoption=-interaction=nonstopmode" 46 | - name: Check pdf files 47 | run: | 48 | set -e 49 | file test/test.pdf | grep -q ' PDF ' 50 | file test/math.pdf | grep -q ' PDF ' 51 | file test/biblatex.pdf | grep -q ' PDF ' 52 | file test/minted.pdf | grep -q ' PDF ' 53 | - uses: actions/upload-artifact@v4 54 | with: 55 | name: test-directory 56 | path: test/ 57 | -------------------------------------------------------------------------------- /.vscode/ltex.dictionary.en-US.txt: -------------------------------------------------------------------------------- 1 | TeXLive 2 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Changelog 2 | 3 | All notable changes to this project will be documented in this file. 4 | 5 | This project cannot adhere to [Semantic Versioning](http://semver.org/), because it builds on TeXLive, which introduces breaking changes now and then. 6 | Thus, each new version would lead to a new major version. 7 | Instead, we version `YYYY-R`, where `YYYY` is TeXLive version this image is based on and `R` is numbering different releases in that cycle using characters. 8 | E.g., `2021-A`, `2021-B`, ... 9 | We use letters instead of numbers to avoid confusion with the automatic builds such as `2021-05-15`. 10 | 11 | ## [edge] 12 | 13 | This version is continuously built based on [DANTE e.V.'s docker-texlive `edge` build](https://github.com/dante-ev/docker-texlive/). 14 | 15 | ## [2025-A] - 2025-05-10 16 | 17 | - Base on [DANTE e.V.'s docker-texlive 2025-A](https://github.com/dante-ev/docker-texlive/releases/tag/2025-A) 18 | 19 | ## [2024-B] - 2025-02-13 20 | 21 | - Base on [DANTE e.V.'s docker-texlive 2024-B](https://github.com/dante-ev/docker-texlive/releases/tag/2024-B) 22 | 23 | ## [2024-A] - 2025-02-13 24 | 25 | - Base on [DANTE e.V.'s docker-texlive 2024-A](https://github.com/dante-ev/docker-texlive/releases/tag/2024-A) 26 | 27 | ## [2023-A] - 2023-05-12 28 | 29 | - Base on [DANTE e.V.'s docker-texlive 2023-A](https://github.com/dante-ev/docker-texlive/releases/tag/2023-A) 30 | - Added support for `extra_font_packages` to install fonts from zip files 31 | 32 | ## [2020-A] - 2021-09-18 33 | 34 | - Base on [DANTE e.V.'s docker-texlive 2020-A](https://github.com/dante-ev/docker-texlive/releases/tag/2020-A) 35 | 36 | ## [2019-A] - 2021-09-15 37 | 38 | - Base on [DANTE e.V.'s docker-texlive 2019-A](https://github.com/dante-ev/docker-texlive/releases/tag/2019-A) 39 | 40 | ## [2021-C] - 2021-08-04 41 | 42 | - Base on [DANTE e.V.'s docker-texlive 2021-C](https://github.com/dante-ev/docker-texlive/releases/tag/2021-C) 43 | 44 | ## [2021-B] - 2021-06-11 45 | 46 | - Base on [DANTE e.V.'s docker-texlive 2021-B](https://github.com/dante-ev/docker-texlive/releases/tag/2021-B) 47 | 48 | ## [2021-A] - 2021-05-18 49 | 50 | ### Changed 51 | 52 | - Base on [DANTE e.V.'s docker-texlive 2021-A](https://github.com/dante-ev/docker-texlive/releases/tag/2021-A) 53 | - Offer `@edge` and `@latest` tags 54 | 55 | ## [0.2.0] - 2019-09-25 56 | 57 | ### Changed 58 | 59 | - Changed name and description of the GitHub action 60 | 61 | ## [0.1.0] - 2019-09-25 62 | 63 | Initial public release 64 | 65 | [edge]: https://github.com/dante-ev/latex-action/compare/2025-A...edge 66 | [2025-A]: https://github.com/dante-ev/latex-action/compare/2024-B...2025-A 67 | [2024-B]: https://github.com/dante-ev/latex-action/compare/2024-A...2024-B 68 | [2024-A]: https://github.com/dante-ev/latex-action/compare/2023-A...2024-A 69 | [2023-A]: https://github.com/dante-ev/latex-action/compare/2021-C...2023-A 70 | [2021-C]: https://github.com/dante-ev/latex-action/compare/2021-B...2021-C 71 | [2021-B]: https://github.com/dante-ev/latex-action/compare/2021-A...2021-B 72 | [2021-A]: https://github.com/dante-ev/latex-action/compare/v0.2.0...2021-A 73 | [2020-A]: https://github.com/dante-ev/latex-action/compare/2019-A...2020-A 74 | [2019-A]: https://github.com/dante-ev/latex-action/compare/2021-C...2019-A 75 | [0.2.0]: https://github.com/dante-ev/latex-action/compare/v0.1.0...v0.2.0 76 | [0.1.0]: https://github.com/dante-ev/latex-action/releases/tag/v0.1.0 77 | -------------------------------------------------------------------------------- /Dockerfile: -------------------------------------------------------------------------------- 1 | FROM ghcr.io/dante-ev/texlive:edge 2 | 3 | WORKDIR /root 4 | 5 | COPY \ 6 | entrypoint.sh \ 7 | /root/ 8 | 9 | ENTRYPOINT ["/root/entrypoint.sh"] 10 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2019 Cheng XU, Oliver Kopp 4 | Copyright (c) 2021 Oliver Kopp 5 | 6 | Permission is hereby granted, free of charge, to any person obtaining a copy 7 | of this software and associated documentation files (the "Software"), to deal 8 | in the Software without restriction, including without limitation the rights 9 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | copies of the Software, and to permit persons to whom the Software is 11 | furnished to do so, subject to the following conditions: 12 | 13 | The above copyright notice and this permission notice shall be included in all 14 | copies or substantial portions of the Software. 15 | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | SOFTWARE. 23 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # latex-action [![GitHub Actions Status](https://github.com/dante-ev/latex-action/workflows/Test%20Github%20Action/badge.svg)](https://github.com/dante-ev/latex-action/actions) 2 | 3 | 🚧 For a more lightweight solution, head to https://github.com/zauguin/install-texlive 🚧 4 | 5 | GitHub Action to compile LaTeX documents. This actions runs on docker using a [maximal TeXLive environment](https://hub.docker.com/r/danteev/texlive/) installed. 6 | 7 | ## Inputs 8 | 9 | * `root_file` 10 | 11 | The root LaTeX file to be compiled. This input is required. 12 | 13 | * `working_directory` 14 | 15 | The working directory for the latex compiler to be invoked. 16 | 17 | * `compiler` 18 | 19 | The LaTeX engine to be used. By default [`latexmk`](https://ctan.org/pkg/latexmk) is used. `latexmk` automates the process of generating LaTeX documents by issuing the appropriate sequence of commands to be run. 20 | 21 | * `args` 22 | 23 | The extra arguments to be passed to the compiler. By default, it is `-pdf -latexoption=-file-line-error -latexoption=-interaction=nonstopmode`. This tells `latexmk` to use `pdflatex`. Refer to [`latexmk` document](http://texdoc.net/texmf-dist/doc/support/latexmk/latexmk.pdf) for more information. 24 | 25 | * `extra_system_packages` 26 | 27 | The extra packages to be installed by [`apt-get`](https://en.wikipedia.org/wiki/APT_(Package_Manager)) separated by space. 28 | 29 | * `extra_font_packages` 30 | 31 | The extra fonts such as some chinese fonts, please package them as a ZIP format. 32 | ```yaml 33 | with: 34 | extra_font_packages: fonts # means fonts.zip 35 | ``` 36 | 37 | ## Examples 38 | 39 | ### Build `main.tex` using `latexmk` 40 | 41 | Note that by default [`latexmk`](https://ctan.org/pkg/latexmk) is used. 42 | `latexmk` automates the process of generating LaTeX documents by issuing the appropriate sequence of commands to be run. 43 | 44 | ```yaml 45 | name: Build LaTeX document 46 | on: [push] 47 | jobs: 48 | build_latex: 49 | runs-on: ubuntu-latest 50 | steps: 51 | - name: Set up Git repository 52 | uses: actions/checkout@v2 53 | - name: Compile LaTeX document 54 | uses: dante-ev/latex-action@latest 55 | with: 56 | root_file: main.tex 57 | ``` 58 | 59 | ### Build `example-class-relations--svg.tex` using `lualatex` 60 | 61 | This is required if one does not trust latexmk and wants to build "by hand" 62 | 63 | ```yaml 64 | name: Build LaTeX document 65 | on: [push] 66 | jobs: 67 | build_latex: 68 | runs-on: ubuntu-latest 69 | steps: 70 | - name: Set up Git repository 71 | uses: actions/checkout@v2 72 | - name: example-class-relations--svg 73 | uses: dante-ev/latex-action@latest 74 | with: 75 | root_file: example-class-relations--svg.tex 76 | compiler: lualatex 77 | args: -interaction=nonstopmode -shell-escape 78 | ``` 79 | 80 | ### "Real" document 81 | 82 | In a "real" document, one would have to encode all steps one after another: 83 | 84 | ```yaml 85 | name: Build LaTeX document 86 | on: [push] 87 | jobs: 88 | build_latex: 89 | runs-on: ubuntu-latest 90 | steps: 91 | - name: Set up Git repository 92 | uses: actions/checkout@v2 93 | - name: pdflatex main 94 | uses: dante-ev/latex-action@latest 95 | with: 96 | root_file: main.tex 97 | compiler: pdflatex 98 | args: -interaction=nonstopmode -shell-escape 99 | - name: bibtex main 100 | uses: dante-ev/latex-action@latest 101 | with: 102 | root_file: main.aux 103 | compiler: bibtex 104 | args: 105 | - name: pdflatex main 106 | uses: dante-ev/latex-action@latest 107 | with: 108 | root_file: main.tex 109 | compiler: pdflatex 110 | args: -interaction=nonstopmode -shell-escape 111 | ``` 112 | 113 | ### Custom build script 114 | 115 | When using a custom shell script for building, one can pass this as follows: 116 | 117 | ```yaml 118 | name: Build LaTeX document 119 | on: [push] 120 | jobs: 121 | build_latex: 122 | runs-on: ubuntu-latest 123 | steps: 124 | - name: Set up Git repository 125 | uses: actions/checkout@v2 126 | - name: release.sh 127 | uses: dante-ev/latex-action@latest 128 | with: 129 | entrypoint: ./release.sh 130 | ``` 131 | 132 | Real life example: 133 | 134 | ## FAQs 135 | 136 | ### How to use XeLaTeX or LuaLaTeX instead of pdfLaTeX? 137 | 138 | By default, this action uses pdfLaTeX. If you want to use XeLaTeX or LuaLaTeX, you can set the `args` to `-xelatex -latexoption=-file-line-error -latexoption=-interaction=nonstopmode` or `-lualatex -latexoption=-file-line-error -latexoption=-interaction=nonstopmode` respectively. Alternatively, you could create a `.latexmkrc` file. Refer to the [`latexmk` document](https://mg.readthedocs.io/latexmk.html) for more information. 139 | Please mind that it is **not recommend** to change the `compiler` parameter, as the by default used `latexmk` has the advantage of determinating the (re)compilation steps automatically and executes them. 140 | 141 | ### How to enable `--shell-escape`? 142 | 143 | To enable `--shell-escape`, you should add it to `args`. For example, set `args` to `-pdf -latexoption=-file-line-error -latexoption=-interaction=nonstopmode -latexoption=-shell-escape` when using pdfLaTeX. 144 | 145 | ### Where does the initial code come from? 146 | 147 | The initial code is from [xu-cheng/latex-action](https://github.com/xu-cheng/latex-action). 148 | The idea there is to initially provide all packages instead of using [texliveonfly](https://ctan.org/pkg/texliveonfly). 149 | Using a full installation, this action also offers to use packages such as [pax](https://ctan.org/pkg/pax), which require other tooling such as perl. 150 | More reasoning is given in [ADR-0002](https://github.com/dante-ev/docker-texlive/blob/master/docs/adr/0002-provide-all-packages.md#provide-all-packages). 151 | 152 | ### How can I speedup the build? 153 | 154 | You can try to use [caching](https://docs.github.com/en/actions/guides/caching-dependencies-to-speed-up-workflows), though be careful as sometimes a LaTeX document needs to be rebuilt completly in order to have a proper result. 155 | 156 | Here is an example that rebuilds uses the cache at most once a day. The files to cache [are taken from the well-known GitHub `.gitignore` templates](https://github.com/github/gitignore/blob/master/TeX.gitignore): 157 | 158 | ```yaml 159 | # https://github.com/actions/cache#creating-a-cache-key 160 | # http://man7.org/linux/man-pages/man1/date.1.html 161 | - name: Get Date 162 | id: get-date 163 | run: | 164 | echo "::set-output name=date::$(/bin/date -u "+%Y%m%d")" 165 | shell: bash 166 | 167 | - name: Cache 168 | uses: actions/cache@v2.1.3 169 | with: 170 | # A list of files, directories, and wildcard patterns to cache and restore 171 | path: | 172 | *.aux 173 | *.lof 174 | *.lot 175 | *.fls 176 | *.out 177 | *.toc 178 | *.fmt 179 | *.fot 180 | *.cb 181 | *.cb2 182 | .*.lb 183 | *.bbl 184 | *.bcf 185 | *.blg 186 | *-blx.aux 187 | *-blx.bib 188 | *.run.xml 189 | key: ${{ runner.os }}-${{ steps.get-date.outputs.date }} 190 | ``` 191 | 192 | ## Where to find my PDF? 193 | 194 | Please use an appropriate GitHub action. 195 | One option is [upload-artifact](https://github.com/actions/upload-artifact), which collects the build artifacts and stores them into a GitHub space. 196 | Another option is to use rsync via [action-rsyncer](https://github.com/Pendect/action-rsyncer). 197 | 198 | ## Available versions 199 | 200 | * `@latest` points to the latest release of [DANTE e.V.'s docker-texlive](https://github.com/dante-ev/docker-texlive) 201 | * `@edge` is the latest development version of [DANTE e.V.'s docker-texlive](https://github.com/dante-ev/docker-texlive) 202 | 203 | ## License 204 | 205 | MIT 206 | -------------------------------------------------------------------------------- /action.yml: -------------------------------------------------------------------------------- 1 | name: LaTeX compilation 2 | description: Compiles latex documents using pdflatex, lualatex, xelatex. Full TeXLive distribution. 3 | author: Cheng XU, Oliver Kopp 4 | inputs: 5 | root_file: 6 | description: The root LaTeX file to be compiled 7 | required: true 8 | working_directory: 9 | description: The working directory for the latex compiler to be invoked 10 | compiler: 11 | description: LaTeX engine to be used 12 | default: latexmk 13 | args: 14 | description: Extra arguments to be passed to the latex compiler 15 | default: "-pdf -latexoption=-file-line-error -latexoption=-interaction=nonstopmode" 16 | extra_system_packages: 17 | description: Install extra packages by apt-get 18 | extra_font_packages: 19 | description: Install fonts packaged in zip format 20 | runs: 21 | using: docker 22 | image: Dockerfile 23 | args: 24 | - ${{ inputs.root_file }} 25 | - ${{ inputs.working_directory }} 26 | - ${{ inputs.compiler }} 27 | - ${{ inputs.args }} 28 | - ${{ inputs.extra_system_packages }} 29 | - ${{ inputs.extra_font_packages }} 30 | branding: 31 | icon: book 32 | color: blue 33 | -------------------------------------------------------------------------------- /entrypoint.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | set -e 4 | 5 | root_file="$1" 6 | working_directory="$2" 7 | compiler="$3" 8 | args="$4" 9 | extra_system_packages="$5" 10 | extra_font_packages="$6" 11 | 12 | if [ -n "$extra_system_packages" ]; then 13 | apt-get update 14 | for pkg in $extra_system_packages; do 15 | echo "Install $pkg by apt" 16 | apt-get -y install "$pkg" 17 | done 18 | fi 19 | 20 | if [ -n "$working_directory" ]; then 21 | cd "$working_directory" 22 | fi 23 | 24 | if [ -n "$extra_font_packages" ]; then 25 | unzip "$extra_font_packages.zip" && \ 26 | mv "$extra_font_packages" /usr/share/fonts/extra_fonts/ && \ 27 | fc-cache -fv && \ 28 | fc-list :lang=zh-cn | sort 29 | fi 30 | 31 | "$compiler" $args "$root_file" 32 | -------------------------------------------------------------------------------- /test/biblatex.tex: -------------------------------------------------------------------------------- 1 | \documentclass{article} 2 | \usepackage[style=ieee]{biblatex} 3 | \addbibresource{ref.bib} 4 | \begin{document} 5 | \cite{article} 6 | \printbibliography 7 | \end{document} 8 | -------------------------------------------------------------------------------- /test/math.tex: -------------------------------------------------------------------------------- 1 | \documentclass{article} 2 | 3 | \usepackage{amsmath} 4 | \usepackage{amssymb} 5 | \usepackage{amsfonts} 6 | \usepackage{mathrsfs} 7 | \usepackage{latexsym} 8 | \usepackage{bm} 9 | 10 | \usepackage[math]{blindtext} 11 | 12 | \begin{document} 13 | \blindmathpaper 14 | \end{document} 15 | -------------------------------------------------------------------------------- /test/minted.tex: -------------------------------------------------------------------------------- 1 | \documentclass{article} 2 | \usepackage{minted} 3 | \begin{document} 4 | \begin{minted}{c} 5 | int main() { 6 | printf("hello, world"); 7 | return 0; 8 | } 9 | \end{minted} 10 | \end{document} 11 | -------------------------------------------------------------------------------- /test/ref.bib: -------------------------------------------------------------------------------- 1 | @article{article, 2 | author = {Authors}, 3 | title = {The title of the work}, 4 | journal = {The name of the journal}, 5 | year = 2019, 6 | } 7 | -------------------------------------------------------------------------------- /test/test.tex: -------------------------------------------------------------------------------- 1 | \documentclass{article} 2 | \usepackage{blindtext} 3 | \begin{document} 4 | \blinddocument 5 | \end{document} 6 | --------------------------------------------------------------------------------