-
-
Notifications
You must be signed in to change notification settings - Fork 331
Expand file tree
/
Copy pathexec.sh
More file actions
46 lines (38 loc) · 775 Bytes
/
exec.sh
File metadata and controls
46 lines (38 loc) · 775 Bytes
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
#!/usr/bin/env bash
set -euxo pipefail
if [ -z "${GITHUB_REPOSITORY_ID:-}" ]; then
echo "GITHUB_REPOSITORY_ID is unset!"
exit 1
fi
if [ -z "${1:-}" ]; then
echo "Arguments are unset!"
exit 1
fi
ENVVARS=()
COMMAND=()
while (( "${#}" )); do
case "$1" in
-e)
ENVVARS+=("-e")
shift
ENVVARS+=("$1")
shift
;;
--)
shift
while (( "${#}" )); do
COMMAND+=("$1")
shift
done
;;
esac
done
if command -v docker &> /dev/null; then
DOCKER="docker"
elif command -v podman &> /dev/null; then
DOCKER="podman"
else
echo "Could not find docker / podman!"
exit 1
fi
exec "${DOCKER}" exec "${ENVVARS[@]}" "${GITHUB_REPOSITORY_ID}" "${COMMAND[@]}"