Skip to content
This repository was archived by the owner on May 6, 2020. It is now read-only.

Commit e64ab09

Browse files
Can Elkatmışsudomateo
authored andcommitted
Fixing terraform apply comments (#103)
* Bugfix for succeeded apply comments * Align with terraform plan * Delete CONTRIBUTING.md * Removing extra whitespace
1 parent 0441f90 commit e64ab09

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

src/terraform_apply.sh

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,23 +5,26 @@ function terraformApply {
55
echo "apply: info: applying Terraform configuration in ${tfWorkingDir}"
66
applyOutput=$(terraform apply -auto-approve -input=false 2>&1)
77
applyExitCode=${?}
8+
applyCommentStatus="Failed"
89

910
# Exit code of 0 indicates success. Print the output and exit.
1011
if [ ${applyExitCode} -eq 0 ]; then
1112
echo "apply: info: successfully applied Terraform configuration in ${tfWorkingDir}"
1213
echo "${applyOutput}"
1314
echo
14-
exit ${applyExitCode}
15+
applyCommentStatus="Success"
1516
fi
1617

1718
# Exit code of !0 indicates failure.
18-
echo "apply: error: failed to apply Terraform configuration in ${tfWorkingDir}"
19-
echo "${applyOutput}"
20-
echo
19+
if [ ${applyExitCode} -ne 0 ]; then
20+
echo "apply: error: failed to apply Terraform configuration in ${tfWorkingDir}"
21+
echo "${applyOutput}"
22+
echo
23+
fi
2124

2225
# Comment on the pull request if necessary.
2326
if [ "$GITHUB_EVENT_NAME" == "pull_request" ] && [ "${tfComment}" == "1" ]; then
24-
applyCommentWrapper="#### \`terraform apply\` Failed
27+
applyCommentWrapper="#### \`terraform apply\` ${applyCommentStatus}
2528
<details><summary>Show Output</summary>
2629
2730
\`\`\`

0 commit comments

Comments
 (0)