Skip to content

Commit

Permalink
Terraform: Review facilitation actions (#1)
Browse files Browse the repository at this point in the history
  • Loading branch information
parisk authored Nov 13, 2024
2 parents d140462 + 886d5be commit 457d092
Show file tree
Hide file tree
Showing 4 changed files with 96 additions and 0 deletions.
21 changes: 21 additions & 0 deletions tf-lint/action.yml
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 }}

21 changes: 21 additions & 0 deletions tf-plan/action.yml
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 }}
42 changes: 42 additions & 0 deletions tf-report/action.yml
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
})
12 changes: 12 additions & 0 deletions tf-setup/action.yml
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 }}

0 comments on commit 457d092

Please sign in to comment.