forked from xu-cheng/latex-action
-
Notifications
You must be signed in to change notification settings - Fork 0
/
entrypoint.sh
executable file
·52 lines (41 loc) · 1.01 KB
/
entrypoint.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#!/bin/sh
set -e
warn() {
echo "::warning :: $1"
}
error() {
echo "::error :: $1"
exit 1
}
root_file="$1"
working_directory="$2"
compiler="$3"
args="$4"
extra_system_packages="$5"
extra_local_packages="$6"
if [ -z "$root_file" ]; then
error "Input 'root_file' is missing."
fi
if [ -z "$compiler" ] && [ -z "$args" ]; then
warn "Input 'compiler' and 'args' are both empty. Reset them to default values."
compiler="latexmk"
args="-pdf -file-line-error -interaction=nonstopmode"
fi
if [ -n "$extra_system_packages" ]; then
for pkg in $extra_system_packages; do
echo "Install $pkg by apk"
apk --no-cache add "$pkg"
done
fi
if [ -n "$extra_local_packages" ]; then
export TEXINPUTS=".:${PWD}/${extra_local_packages}/:${TEXINPUTS}"
echo "Using TEXINPUTS=${TEXINPUTS}"
fi
if [ -n "$working_directory" ]; then
cd "$working_directory"
fi
if [ ! -f "$root_file" ]; then
error "File '$root_file' cannot be found from the directory '$PWD'."
fi
# shellcheck disable=SC2086
"$compiler" $args "$root_file"