Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
zydou committed Aug 29, 2023
2 parents 9cc13ea + 9ae8710 commit 5659aa0
Show file tree
Hide file tree
Showing 3 changed files with 93 additions and 65 deletions.
35 changes: 11 additions & 24 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ Each input is provided as a key inside the `with` section of the action.

- `root_file` (**required**, defaults to: "")

The root LaTeX file to be compiled. You can also pass multiple files as a multi-line string to compile multiple documents. For example:
The root LaTeX file to be compiled. You can also pass multiple files as a multi-line string to compile multiple documents. Each file path will be interpreted as bash glob pattern. For example:

```yaml
- uses: zydou/latex-action@v3
Expand All @@ -46,17 +46,6 @@ Each input is provided as a key inside the `with` section of the action.
file2.tex
```

- `glob_root_file` (optional, defaults to: "false")

If set, interpret the `root_file` input as bash glob pattern. For example:

```yaml
- uses: zydou/latex-action@v3
with:
root_file: '*.tex'
glob_root_file: true
```

- `working_directory` (optional, defaults to: ".")

The working directory for this action.
Expand All @@ -83,7 +72,7 @@ Each input is provided as a key inside the `with` section of the action.

- `extra_fonts` (optional, defaults to: "")

Install extra `.ttf`/`.otf` fonts to be used by `fontspec`. You can also pass multiple files as a multi-line string. Each file path will be interpreted as glob pattern. For example:
Install extra `.ttf`/`.otf` fonts to be used by `fontspec`. You can also pass multiple files as a multi-line string. Each file path will be interpreted as bash glob pattern. For example:

```yaml
- uses: zydou/latex-action@v3
Expand All @@ -102,6 +91,14 @@ Each input is provided as a key inside the `with` section of the action.

Arbitrary bash codes to be executed after compiling LaTeX documents. For example, `post_compile: "latexmk -c"` to clean up temporary files.
- `texlive_version` (optional, defaults to: "latest")

The TeX Live version to be used. Currently, you can choose from `2018`, `2019`, `2020`, `2021`, `2022`, `2023`, or `latest`.

- `debian_release` (optional, defaults to: "trixie")

The Debian release of base image to be used. Currently, you can choose from `buster`, `bullseye`, `bookworm`, or `trixie`.

**The following inputs are only valid if the input `compiler` is not changed.**

- `latexmk_shell_escape` (optional, defaults to: "false")
Expand All @@ -116,14 +113,6 @@ Each input is provided as a key inside the `with` section of the action.

Instruct `latexmk` to use XeLaTeX.

- `texlive_version` (optional, defaults to: "latest")

The TeX Live version to be used. Currently, you can choose from `2018`, `2019`, `2020`, `2021`, `2022`, `2023`, or `latest`.

- `debian_release` (optional, defaults to: "trixie")

The Debian release of base image to be used. Currently, you can choose from `buster`, `bullseye`, `bookworm`, or `trixie`.

## Example

```yaml
Expand Down Expand Up @@ -254,11 +243,9 @@ Sometimes you may have custom package (`.sty`) or class (`.cls`) files in other
with:
root_file: main.tex
env:
TEXINPUTS: '.:./custom_template//:'
TEXINPUTS: ".:./custom_template//:"
```

Noted that you should NOT use `{{ github.workspace }}` or `$GITHUB_WORKSPACE` in `TEXINPUTS`. This action works in a separated docker container, where the workspace directory is mounted into it. Therefore, the workspace directory inside the docker container is different from `github.workspace`.

You can find more information of `TEXINPUTS` [here](https://tex.stackexchange.com/a/93733).

### It fails to build the document, how to solve it?
Expand Down
75 changes: 62 additions & 13 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,6 @@ inputs:
root_file:
description: The root LaTeX file to be compiled
required: true
glob_root_file:
description: Interpret the root_file input as bash glob pattern
default: "false"
working_directory:
description: The working directory for this action
default: .
Expand All @@ -30,11 +27,8 @@ inputs:
args:
description: Extra arguments to be passed to the LaTeX engine
default: -pdf -file-line-error -halt-on-error -interaction=nonstopmode
extra_packages:
description: "[Deprecated] Install extra packages by tlmgr"
default: ""
extra_system_packages:
description: Install extra packages by apt
description: Install extra packages by apt-get
default: ""
extra_fonts:
description: Install extra .ttf/.otf fonts.
Expand All @@ -46,33 +40,88 @@ inputs:
description: Arbitrary bash codes to be executed after compiling LaTeX documents
default: ""
latexmk_shell_escape:
default: "false"
description: Instruct latexmk to enable --shell-escape
default: "false"
latexmk_use_lualatex:
description: Instruct latexmk to use LuaLaTeX
default: "false"
latexmk_use_xelatex:
description: Instruct latexmk to use XeLaTeX
default: "false"

runs:
using: composite
steps:
- shell: bash
run: >
docker run --rm
-v "${PWD}":/github/workspace
-v "${GITHUB_ACTION_PATH}/entrypoint.sh":/entrypoint.sh
-w /github/workspace
-e "ACTIONS_CACHE_URL"
-e "ACTIONS_RUNTIME_TOKEN"
-e "ACTIONS_RUNTIME_URL"
-e "GITHUB_ACTION_REF"
-e "GITHUB_ACTION_REPOSITORY"
-e "GITHUB_ACTION"
-e "GITHUB_ACTOR_ID"
-e "GITHUB_ACTOR"
-e "GITHUB_API_URL"
-e "GITHUB_BASE_REF"
-e "GITHUB_ENV"
-e "GITHUB_EVENT_NAME"
-e "GITHUB_EVENT_PATH"
-e "GITHUB_GRAPHQL_URL"
-e "GITHUB_HEAD_REF"
-e "GITHUB_JOB"
-e "GITHUB_OUTPUT"
-e "GITHUB_PATH"
-e "GITHUB_REF_NAME"
-e "GITHUB_REF_PROTECTED"
-e "GITHUB_REF_TYPE"
-e "GITHUB_REF"
-e "GITHUB_REPOSITORY_ID"
-e "GITHUB_REPOSITORY_OWNER_ID"
-e "GITHUB_REPOSITORY_OWNER"
-e "GITHUB_REPOSITORY"
-e "GITHUB_RETENTION_DAYS"
-e "GITHUB_RUN_ATTEMPT"
-e "GITHUB_RUN_ID"
-e "GITHUB_RUN_NUMBER"
-e "GITHUB_SERVER_URL"
-e "GITHUB_SHA"
-e "GITHUB_STATE"
-e "GITHUB_STEP_SUMMARY"
-e "GITHUB_TRIGGERING_ACTOR"
-e "GITHUB_WORKFLOW_REF"
-e "GITHUB_WORKFLOW_SHA"
-e "GITHUB_WORKFLOW"
-e "GITHUB_WORKSPACE"
-e "HOME"
-e "RUNNER_ARCH"
-e "RUNNER_ENVIRONMENT"
-e "RUNNER_NAME"
-e "RUNNER_OS"
-e "RUNNER_TEMP"
-e "RUNNER_TOOL_CACHE"
-e "RUNNER_WORKSPACE"
-e "TEXINPUTS"
-e CI=true
-e GITHUB_ACTIONS=true
-v "/var/run/docker.sock":"/var/run/docker.sock"
-v "$HOME:$HOME"
-v "$GITHUB_ENV:$GITHUB_ENV"
-v "$GITHUB_OUTPUT:$GITHUB_OUTPUT"
-v "$GITHUB_STEP_SUMMARY:$GITHUB_STEP_SUMMARY"
-v "$GITHUB_PATH:$GITHUB_PATH"
-v "$GITHUB_WORKSPACE:$GITHUB_WORKSPACE"
-v "$GITHUB_ACTION_PATH/entrypoint.sh":/entrypoint.sh
-w "$GITHUB_WORKSPACE"
--entrypoint "/entrypoint.sh"
zydou/texlive:${{ inputs.texlive_version }}-${{ inputs.debian_release }}
"${{ inputs.root_file }}"
"${{ inputs.glob_root_file }}"
"${{ inputs.working_directory }}"
"${{ inputs.work_in_root_file_dir }}"
"${{ inputs.continue_on_error }}"
"${{ inputs.compiler }}"
"${{ inputs.args }}"
"${{ inputs.extra_packages }}"
"${{ inputs.extra_system_packages }}"
"${{ inputs.extra_fonts }}"
"${{ inputs.pre_compile }}"
Expand Down
48 changes: 20 additions & 28 deletions entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,26 +17,24 @@ function error() {
}

root_file="${1}"
glob_root_file="${2}"
working_directory="${3}"
work_in_root_file_dir="${4}"
continue_on_error="${5}"
compiler="${6}"
args="${7}"
extra_packages="${8}"
extra_system_packages="${9}"
extra_fonts="${10}"
pre_compile="${11}"
post_compile="${12}"
latexmk_shell_escape="${13}"
latexmk_use_lualatex="${14}"
latexmk_use_xelatex="${15}"
working_directory="${2}"
work_in_root_file_dir="${3}"
continue_on_error="${4}"
compiler="${5}"
args="${6}"
extra_system_packages="${7}"
extra_fonts="${8}"
pre_compile="${9}"
post_compile="${10}"
latexmk_shell_escape="${11}"
latexmk_use_lualatex="${12}"
latexmk_use_xelatex="${13}"

# install git on old images
if ! command -v git &> /dev/null; then
apt-get update -qq && apt-get install -qq -y git
fi
git config --system --add safe.directory /github/workspace
git config --system --add safe.directory "${GITHUB_WORKSPACE}"

if [[ -z "${root_file}" ]]; then
error "Input 'root_file' is missing."
Expand All @@ -49,15 +47,13 @@ if [[ ! -d "${working_directory}" ]]; then
fi
cd "${working_directory}"

if [[ "${glob_root_file}" = "true" ]]; then
expanded_root_file=()
for pattern in "${root_file[@]}"; do
# shellcheck disable=SC2206
expanded=(${pattern})
expanded_root_file+=("${expanded[@]}")
done
root_file=("${expanded_root_file[@]}")
fi
expanded_root_file=()
for pattern in "${root_file[@]}"; do
# shellcheck disable=SC2206
expanded=(${pattern})
expanded_root_file+=("${expanded[@]}")
done
root_file=("${expanded_root_file[@]}")

if [[ -z "${compiler}" && -z "${args}" ]]; then
warn "Input 'compiler' and 'args' are both empty. Reset them to default values."
Expand Down Expand Up @@ -143,10 +139,6 @@ if [[ -n "${extra_fonts}" ]]; then
fc-cache -fv
fi

if [[ -n "${extra_packages}" ]]; then
warn "Input 'extra_packages' is deprecated. We now build LaTeX document with full TeXLive installed."
fi

if [[ -n "${pre_compile}" ]]; then
info "Run pre compile commands"
eval "${pre_compile}"
Expand Down

0 comments on commit 5659aa0

Please sign in to comment.