Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Terraform: Review facilitation actions #1

Merged
merged 6 commits into from
Nov 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 }}