Today I tried setting up LaTeX compilation via GitHub Actions for my private repository for my bachelor thesis. I wanted to use your latex-action
.
Unfortunately for me, my institute has a strict requirement for all thesis to be set in the Microsoft font "Arial", which is somewhat challenging when trying to set up a LaTeX document in an Ubuntu environment, such as my own personal computer ... or the docker container which your latex-action
uses.
On my personal computer I was able to make the Arial font available by running the following commands:
sudo apt install ttf-mscorefonts-installer
sudo fc-cache -f
I was then able to confirm that the Arial font was successfully installed, using:
sudo fc-match Arial
(expected output: Arial.ttf: "Arial" "Regular" )
Unfortunately, the first command ( apt install
) asks you to explicitly accept a license agreement of some sort, which requires interactive input (select yes, hit enter...). To circumvent this in a script, one may use the following commands instead:
echo ttf-mscorefonts-installer msttcorefonts/accepted-mscorefonts-eula select true | sudo debconf-set-selections
sudo apt-get install ttf-mscorefonts-installer
sudo fc-cache -f
(following the suggestion in https://askubuntu.com/a/25614)
Now, how do I insert this into either a) my own workflow yaml file in my repo b) a custom fork of your latex-action repo (if this is necessary) or c) a custom fork of your latex-docker image (if this is necessary) ?
Thinks I have tried already:
-
Add the above commands as additional step
in my workflow yaml (the build_latex
job):
jobs:
build_latex:
runs-on: ubuntu-latest
steps:
- name: Set up Git repository
uses: actions/checkout@v2
- name: Install Arial font
run: |
echo ttf-mscorefonts-installer msttcorefonts/accepted-mscorefonts-eula select true | sudo debconf-set-selections
sudo apt-get install ttf-mscorefonts-installer
sudo fc-cache -f
fc-match Arial
- name: Compile LaTeX document
uses: xu-cheng/latex-action@v2
with:
root_file: main.tex
working_directory: src
latexmk_use_xelatex: true
This worked, it installed Arial successfully, but I realized that it won't make any difference to the compilation step, because this doesn't affect the content of the Docker container in any way. It won't help me at all, if the Arial font is only available on the GitHub runner machine that's executing the workflow, but not inside the container.
-
Add the above code to the pre_compile
section of your action:
jobs:
build_latex:
runs-on: ubuntu-latest
steps:
- name: Set up Git repository
uses: actions/checkout@v2
- name: Compile LaTeX document
uses: xu-cheng/latex-action@v2
with:
root_file: main.tex
working_directory: src
latexmk_use_xelatex: true
pre_compile: "echo ttf-mscorefonts-installer msttcorefonts/accepted-mscorefonts-eula select true | sudo debconf-set-selections && sudo apt-get install ttf-mscorefonts-installer && sudo fc-cache -f"
This did not work, because I got a /root/entrypoint.sh: line 105: sudo: command not found
error. I already expected this to happen, because I always run into all kinds of permission issues when I dabble in Docker (as a Docker and Linux noob ...). Using this approach, but deleting the sudo
everywhere yielded a /root/entrypoint.sh: line 105: debconf-set-selections: command not found
error, so even if the sudo
problem can be solved, I would still run into problems.
-
Fork the latex-action
repository, and add additional commands to the Dockerfile:
RUN echo "ttf-mscorefonts-installer msttcorefonts/accepted-mscorefonts-eula select true" | debconf-set-selections
RUN apt-get install -y --no-install-recommends fontconfig ttf-mscorefonts-installer
# refresh system font cache
RUN fc-cache -f -v
... of course this means I also had to change the workflow yaml in the thesis repository to point to my fork of the latex-action
repo, by replacing xu-cheng/latex-action@v2
with PaulOxxx1/latex-action@master
. However, when trying to build the Docker container, I again get the error: /bin/sh: debconf-set-selections: not found
. I guess it makes sense that I would get the same error as in 2) ... both are using the same image, from latex-docker
...
Is there anything I can try in addition?
Thank you :)