forked from hashicorp/setup-packer
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathentrypoint.sh
More file actions
executable file
·43 lines (34 loc) · 976 Bytes
/
entrypoint.sh
File metadata and controls
executable file
·43 lines (34 loc) · 976 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
#!/usr/bin/env bash
set -e
# fail if INPUT_COMMAND is not set
if [ -z "${INPUT_COMMAND}" ]; then
echo "Required variable \`command\` is missing"
exit 1
fi
if [ -n "${INPUT_WORKING_DIRECTORY}" ]; then
cd "${INPUT_WORKING_DIRECTORY}"
fi
# assemble operation
if [ -z "${INPUT_ARGUMENTS}" ]; then
OPERATION="packer ${INPUT_COMMAND}"
else
OPERATION="packer ${INPUT_COMMAND} ${INPUT_ARGUMENTS}"
fi
echo "::debug:: Executing command: ${OPERATION}"
# cast INPUT_TARGET string to "array"
# shellcheck disable=SC2206
TARGETS=(${INPUT_TARGET})
# iterate over target(s)
for TARGET in "${TARGETS[@]}"; do
echo "::debug:: Processing target ${TARGET}"
# shellcheck disable=SC2086
${OPERATION} "${TARGET}"
done
# if we're using manifest post processor dump the manifest to variable.
FILE=./packer-manifest.json
if [ -f "$FILE" ]; then
MANIFEST=$(cat $FILE | tr '\n' ' ')
echo "manifest=$MANIFEST" >> $GITHUB_OUTPUT
else
echo "manifest=''" >> $GITHUB_OUTPUT
fi