-
-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy pathaction.sh
More file actions
executable file
·151 lines (138 loc) · 4.02 KB
/
action.sh
File metadata and controls
executable file
·151 lines (138 loc) · 4.02 KB
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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
#!/usr/bin/env bash
set -eo pipefail
random_token() {
tr -dc A-Za-z0-9 </dev/urandom 2>/dev/null | head -c 32
echo ""
}
run() {
token="$(random_token)"
echo "::stop-commands::${token}"
echo -e "\033[1;34m${*@Q}\033[0m"
echo "::${token}::"
"$@"
}
error() {
echo "::error :: $1"
exit 1
}
if [[ -n "$INPUT_TEXLIVE_VERSION" && -n "$INPUT_DOCKER_IMAGE" ]]; then
error "Input 'texlive_version' and 'docker_image' cannot co-exist".
fi
if [[ -n "$INPUT_SCHEME" && -n "$INPUT_DOCKER_IMAGE" ]]; then
error "Input 'scheme' and 'docker_image' cannot co-exist".
fi
if [[ -n "$INPUT_OS" && -n "$INPUT_DOCKER_IMAGE" ]]; then
error "Input 'os' and 'docker_image' cannot co-exist".
fi
if [[ -z "$INPUT_OS" ]]; then
INPUT_OS="alpine"
fi
if [[ "$INPUT_OS" != "alpine" && "$INPUT_OS" != "debian" ]]; then
error "Input 'os' can only be either 'alpine' or 'debian'".
fi
if [[ -z "$INPUT_SCHEME" ]]; then
INPUT_SCHEME="full"
fi
if [[ "$INPUT_SCHEME" != "full" && "$INPUT_SCHEME" != "small" ]]; then
error "Input 'scheme' can only be either 'full' or 'small'".
fi
if [[ -z "$INPUT_DOCKER_IMAGE" ]]; then
case "$INPUT_TEXLIVE_VERSION" in
"" | "latest" | "2025")
if [[ "$INPUT_OS" = "alpine" ]]; then
if [[ "$INPUT_SCHEME" = "full" ]]; then
INPUT_DOCKER_IMAGE="ghcr.io/xu-cheng/texlive-alpine:latest"
else
INPUT_DOCKER_IMAGE="ghcr.io/xu-cheng/texlive-alpine-small:latest"
fi
else
if [[ "$INPUT_SCHEME" = "full" ]]; then
INPUT_DOCKER_IMAGE="ghcr.io/xu-cheng/texlive-debian:latest"
else
error "Input 'scheme' can only be 'full' when input 'os' is 'debian'"
fi
fi
;;
"2020" | "2021" | "2022" | "2023" | "2024")
if [[ "$INPUT_SCHEME" = "full" ]]; then
if [[ "$INPUT_OS" = "alpine" ]]; then
INPUT_DOCKER_IMAGE="ghcr.io/xu-cheng/texlive-historic-alpine:$INPUT_TEXLIVE_VERSION"
else
INPUT_DOCKER_IMAGE="ghcr.io/xu-cheng/texlive-historic-debian:$INPUT_TEXLIVE_VERSION"
fi
else
error "Input 'scheme' can only be 'full' when historic TeXLive is used"
fi
;;
*)
error "TeX Live version $INPUT_TEXLIVE_VERSION is not supported. The currently supported versions are 2020-2025 or latest."
;;
esac
fi
# ref: https://docs.miktex.org/manual/envvars.html
run docker run --rm \
-e "BIBINPUTS" \
-e "BSTINPUTS" \
-e "MFINPUTS" \
-e "TEXINPUTS" \
-e "TFMFONTS" \
-e "HOME" \
-e "GITHUB_ACTION" \
-e "GITHUB_ACTION_REF" \
-e "GITHUB_ACTION_REPOSITORY" \
-e "GITHUB_ACTOR" \
-e "GITHUB_ACTOR_ID" \
-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" \
-e "GITHUB_REF_NAME" \
-e "GITHUB_REF_PROTECTED" \
-e "GITHUB_REF_TYPE" \
-e "GITHUB_REPOSITORY" \
-e "GITHUB_REPOSITORY_ID" \
-e "GITHUB_REPOSITORY_OWNER" \
-e "GITHUB_REPOSITORY_OWNER_ID" \
-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" \
-e "GITHUB_WORKFLOW_REF" \
-e "GITHUB_WORKFLOW_SHA" \
-e "GITHUB_WORKSPACE" \
-e "RUNNER_ARCH" \
-e "RUNNER_ENVIRONMENT" \
-e "RUNNER_NAME" \
-e "RUNNER_OS" \
-e "RUNNER_TEMP" \
-e "RUNNER_TOOL_CACHE" \
-e "RUNNER_WORKSPACE" \
-e "ACTIONS_CACHE_URL" \
-e "ACTIONS_RUNTIME_TOKEN" \
-e "ACTIONS_RUNTIME_URL" \
-e GITHUB_ACTIONS=true \
-e CI=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" \
-w "$GITHUB_WORKSPACE" \
"$INPUT_DOCKER_IMAGE" \
/bin/bash -eo pipefail -c -- \
"$INPUT_RUN"