-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit a4af82f
Showing
3 changed files
with
57 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
FROM hashicorp/terraform:0.12.12 | ||
|
||
LABEL "com.github.actions.name"="terraform validate" | ||
LABEL "com.github.actions.description"="Validate the terraform files in a directory" | ||
LABEL "com.github.actions.icon"="alert-triangle" | ||
LABEL "com.github.actions.color"="purple" | ||
|
||
LABEL "repository"="https://github.com/hashicorp/terraform-github-actions" | ||
LABEL "homepage"="http://github.com/hashicorp/terraform-github-actions" | ||
LABEL "maintainer"="HashiCorp Terraform Team <[email protected]>" | ||
|
||
RUN apk --update --no-cache add jq curl bash | ||
|
||
COPY entrypoint.sh /entrypoint.sh | ||
ENTRYPOINT ["/entrypoint.sh"] |
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,4 @@ | ||
# Terraform Validate Action | ||
Runs `terraform validate` to validate the terraform files in a directory. | ||
|
||
See [https://www.terraform.io/docs/github-actions/actions/validate.html](https://www.terraform.io/docs/github-actions/actions/validate.html). |
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,38 @@ | ||
#!/bin/bash | ||
set -e | ||
set -o pipefail | ||
|
||
if [[ -n "$TOKEN" ]]; then | ||
GITHUB_TOKEN=$TOKEN | ||
fi | ||
|
||
if [[ -z "$GITHUB_TOKEN" ]]; then | ||
echo "Set the GITHUB_TOKEN env variable." | ||
exit 1 | ||
fi | ||
|
||
URI=https://api.github.com | ||
API_VERSION=v3 | ||
API_HEADER="Accept: application/vnd.github.${API_VERSION}+json" | ||
AUTH_HEADER="Authorization: token ${GITHUB_TOKEN}" | ||
|
||
NO_BRANCH_DELETED_EXIT_CODE=${NO_BRANCH_DELETED_EXIT_CODE:-0} | ||
|
||
main(){ | ||
action=$(jq --raw-output .action "$GITHUB_EVENT_PATH") | ||
merged=$(jq --raw-output .pull_request.merged "$GITHUB_EVENT_PATH") | ||
|
||
echo "DEBUG -> action: $action merged: $merged" | ||
|
||
|
||
ref=$(jq --raw-output .pull_request.head.ref "$GITHUB_EVENT_PATH") | ||
owner=$(jq --raw-output .pull_request.head.repo.owner.login "$GITHUB_EVENT_PATH") | ||
repo=$(jq --raw-output .pull_request.head.repo.name "$GITHUB_EVENT_PATH") | ||
|
||
|
||
echo ::set-env name=BRANCH_NAME::${ref} | ||
|
||
exit 0 | ||
} | ||
|
||
main "$@" |