Skip to content

Commit

Permalink
Moved Dockerfile to validate directory. Also added the entrypoint
Browse files Browse the repository at this point in the history
  • Loading branch information
dawitnida committed Apr 4, 2019
1 parent b12f706 commit 37c6eb7
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
File renamed without changes.
25 changes: 25 additions & 0 deletions validate/entrypoint.sh
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

0 comments on commit 37c6eb7

Please sign in to comment.