-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Assuming you know how to use packer, we don't need to setup an argument template for this. This also makes the whole action more flexible.
- Loading branch information
Showing
3 changed files
with
16 additions
and
46 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,34 +1,7 @@ | ||
#!/bin/bash | ||
set -e | ||
set -ex | ||
|
||
cd "${INPUT_WORKDIR:-.}" | ||
|
||
# By default, HCL_MODE is disabled | ||
HCL_MODE=false | ||
if [[ ${INPUT_TEMPLATEFILE} == '.' || ${INPUT_TEMPLATEFILE} =~ '*.pkr.hcl' ]]; then | ||
HCL_MODE=true | ||
fi | ||
echo "[INFO] HCL_MODE is ${HCL_MODE}" | ||
|
||
if [[ "${HCL_MODE}" == false && ! -f "${INPUT_TEMPLATEFILE}" ]]; then | ||
echo "Error! Template file [${INPUT_TEMPLATEFILE}] is not found!" | ||
exit 1 | ||
fi | ||
|
||
# Validate the template (Currently doesn't work with HCL files) | ||
if [[ "${HCL_MODE}" == false ]]; then | ||
packer validate ${INPUT_TEMPLATEFILE} | ||
if [[ $? -ne 0 ]]; then | ||
echo "Error! Packer template is not valid" | ||
exit 1 | ||
fi | ||
fi | ||
|
||
if [[ -f "${INPUT_VARFILE}" ]]; then | ||
VAR_FILE_FLAG="-var-file=${INPUT_VARFILE}" | ||
else | ||
VAR_FILE_FLAG="" | ||
fi | ||
|
||
# Run packer build | ||
packer build ${VAR_FILE_FLAG} ${INPUT_TEMPLATEFILE} | ||
# Run packer with the given arguments | ||
packer ${INPUT_PACKERARGS} |