Skip to content

Commit b25b386

Browse files
committed
entrypoint.sh: better messages for incorrect inputs for the action
Github Action editor automatically generates a template based on the meta data from action.yml. However, it passes empty strings to optional inputs regardless their default values. To remedy the issue, provide better messages and auto reset compiler and args inputs if both of them are empty. Fixes #16.
1 parent 3608d12 commit b25b386

File tree

2 files changed

+40
-1
lines changed

2 files changed

+40
-1
lines changed

.github/workflows/test.yml

+16
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,22 @@ jobs:
3939
working_directory: test/
4040
compiler: arara
4141
args: "--verbose"
42+
# https://github.com/xu-cheng/latex-action/issues/16
43+
- name: Test Action with Github Default Template
44+
uses: ./
45+
with:
46+
# The root LaTeX file to be compiled
47+
root_file: test/test.tex
48+
# The working directory for the LaTeX engine
49+
working_directory: # optional
50+
# The LaTeX engine to be invoked
51+
compiler: # optional, default is latexmk
52+
# Extra arguments to be passed to the LaTeX engine
53+
args: # optional, default is -pdf -file-line-error -interaction=nonstopmode
54+
# [Deprecated] Install extra packages by tlmgr
55+
extra_packages: # optional
56+
# Install extra packages by apk
57+
extra_system_packages: # optional
4258
- name: Check pdf files
4359
run: |
4460
file test/test.pdf | grep -q ' PDF '

entrypoint.sh

+24-1
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,32 @@
22

33
set -e
44

5+
warn() {
6+
echo "::warning :: $1"
7+
}
8+
9+
error() {
10+
echo "::error :: $1"
11+
exit 1
12+
}
13+
514
root_file="$1"
615
working_directory="$2"
716
compiler="$3"
817
args="$4"
918
extra_packages="$5"
1019
extra_system_packages="$6"
1120

21+
if [ -z "$root_file" ]; then
22+
error "Input 'root_file' is missing."
23+
fi
24+
25+
if [ -z "$compiler" ] && [ -z "$args" ]; then
26+
warn "Input 'compiler' and 'args' are both empty. Reset them to default values."
27+
compiler="latexmk"
28+
args="-pdf -file-line-error -interaction=nonstopmode"
29+
fi
30+
1231
if [ -n "$extra_system_packages" ]; then
1332
for pkg in $extra_system_packages; do
1433
echo "Install $pkg by apk"
@@ -17,12 +36,16 @@ if [ -n "$extra_system_packages" ]; then
1736
fi
1837

1938
if [ -n "$extra_packages" ]; then
20-
echo "::warning ::Input 'extra_packages' is deprecated. We now build LaTeX document with full TeXLive installed."
39+
warn "Input 'extra_packages' is deprecated. We now build LaTeX document with full TeXLive installed."
2140
fi
2241

2342
if [ -n "$working_directory" ]; then
2443
cd "$working_directory"
2544
fi
2645

46+
if [ ! -f "$root_file" ]; then
47+
error "File '$root_file' cannot be found from the directory '$PWD'."
48+
fi
49+
2750
# shellcheck disable=SC2086
2851
"$compiler" $args "$root_file"

0 commit comments

Comments
 (0)