-
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.
Moved Dockerfile to validate directory. Also added the entrypoint
- Loading branch information
Showing
2 changed files
with
25 additions
and
0 deletions.
There are no files selected for viewing
File renamed without changes.
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 |
---|---|---|
@@ -0,0 +1,25 @@ | ||
#!/bin/sh | ||
set -e | ||
|
||
set +e | ||
# Run packer template validator | ||
VALIDATE_OUTPUT=$(sh -c "packer validate -no-color $*" 2>&1) | ||
VALIDATE_SUCCESS=$? | ||
echo "$VALIDATE_OUTPUT" | ||
set -e | ||
|
||
# Capture the result | ||
if [ $VALIDATE_SUCCESS -eq 0 ]; then | ||
exit 0 | ||
fi | ||
|
||
# Spit out the validation output for reference | ||
VALIDATE_COMMENT="#### \`packer validate\` Failed | ||
\`\`\` | ||
$VALIDATE_OUTPUT | ||
\`\`\`" | ||
VALIDATE_PAYLOAD=$(echo '{}' | jq --arg body "$VALIDATE_COMMENT" '.body = $body') | ||
VALIDATE_COMMENTS_URL=$(cat /github/workflow/event.json | jq -r .pull_request.comments_url) | ||
curl -s -S -H "Authorization: token $GITHUB_TOKEN" --header "Content-Type: application/json" --data "$VALIDATE_PAYLOAD" "$VALIDATE_COMMENTS_URL" > /dev/null | ||
|
||
exit $VALIDATE_SUCCESS |