-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Terraform: Review facilitation actions (#1)
- Loading branch information
Showing
4 changed files
with
96 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,21 @@ | ||
name: Terraform lint | ||
description: Initialize terraform, check formating and validate | ||
author: withlogicco | ||
runs: | ||
using: composite | ||
steps: | ||
- id: fmt | ||
run: terraform fmt -check | ||
shell: bash | ||
- id: init | ||
run: terraform init | ||
shell: bash | ||
- id: validate | ||
run: terraform validate -no-color | ||
shell: bash | ||
|
||
outputs: | ||
fmt: | ||
description: Outcome of `terraform fmt -check` | ||
value: ${{ steps.fmt.outcome }} | ||
|
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,21 @@ | ||
name: Terraform Plan | ||
description: Calculate and report back the terraform plan | ||
author: withlogicco | ||
runs: | ||
using: composite | ||
steps: | ||
- id: plan | ||
run: terraform plan -no-color -input=false -out=tf-plan | ||
continue-on-error: true | ||
shell: bash | ||
- id: show | ||
run: terraform show -no-color tf-plan | ||
shell: bash | ||
|
||
outputs: | ||
outcome: | ||
description: Outcome of `terraform plan` | ||
value: ${{ steps.plan.outcome }} | ||
plan: | ||
description: Terraform plan | ||
value: ${{ steps.show.outputs.stdout }} |
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,42 @@ | ||
name: Terraform Report | ||
description: Report Terraform lint and plan in a comment | ||
author: withlogicco | ||
inputs: | ||
plan: | ||
description: Terraform plan | ||
required: true | ||
plan-outcome: | ||
description: Terraform plan outcome | ||
required: true | ||
lint-outcome: | ||
description: Terraform lint outcome | ||
required: true | ||
github-token: | ||
description: The GitHub token to use for commenting the report | ||
required: true | ||
runs: | ||
using: composite | ||
steps: | ||
- uses: actions/github-script@v6 | ||
with: | ||
github-token: ${{ inputs.github-token }} | ||
script: | | ||
const output = `#### Lint 🖌\`${{ inputs.lint-outcome }}\` | ||
#### Plan 📖\`${{ inputs.plan-outcome }}\` | ||
<details><summary>Show Plan</summary> | ||
\`\`\`\n | ||
${{ inputs.plan }} | ||
\`\`\` | ||
</details> | ||
*Pusher: @${{ github.actor }}*`; | ||
github.rest.issues.createComment({ | ||
issue_number: context.issue.number, | ||
owner: context.repo.owner, | ||
repo: context.repo.repo, | ||
body: output | ||
}) |
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,12 @@ | ||
name: Terraform setup | ||
description: Set up Terraform according taking .terraform-version into account | ||
author: withlogicco | ||
runs: | ||
using: composite | ||
steps: | ||
- id: terraform-version | ||
run: echo "version=$(cat .terraform-version)" >> $GITHUB_OUTPUT | ||
shell: bash | ||
- uses: hashicorp/setup-terraform@v2 | ||
with: | ||
terraform_version: ${{ steps.terraform-version.outputs.version }} |