Skip to content

Commit

Permalink
feat(setup): switch to official terramate-setup-action (#11)
Browse files Browse the repository at this point in the history
  • Loading branch information
kaiehrhardt authored Jul 9, 2024
1 parent c7804f7 commit a7dcfd2
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 59 deletions.
4 changes: 1 addition & 3 deletions .github/workflows/test-and-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,7 @@ jobs:
- test-simple
strategy:
matrix:
go-version: ["1.17", "latest"]
terramate-version: ["v0.4.2", "latest"]
terramate-version: ["0.4.2", "latest"]
terraform-version: ["1.5.7", "latest"]
terraform-plan-file: ["out.tfplan", "plan.out"]
tmp-file: ["tmp.txt", "file.tmp"]
Expand All @@ -73,7 +72,6 @@ jobs:
- name: Test
uses: "./"
with:
go-version: ${{ matrix.go-version }}
terramate-version: ${{ matrix.terramate-version }}
terraform-version: ${{ matrix.terraform-version }}
terraform-plan-file: ${{ matrix.terraform-plan-file }}
Expand Down
57 changes: 28 additions & 29 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,35 +78,34 @@ jobs:

## Inputs

| Input Variable | Description | Required | Default Value |
| ----------------------- | ----------------------------------------------------- | -------- | ------------- |
| go-version | The version of Go to use | No | latest |
| terramate-version | The version of Terramate to use | No | latest |
| terraform-version | The version of Terraform to use | No | latest |
| terramate-args | Arguments to pass to each Terramate command | No | --changed |
| terramate-plan-args | Arguments to pass to Terramate in the plan step | No | |
| terramate-apply-args | Arguments to pass to Terramate in the apply step | No | |
| terramate-destroy-args | Arguments to pass to Terramate in the destroy step | No | --reverse |
| terraform-common-args | Arguments to pass to each Terraform command | No | |
| terraform-init-args | Arguments to pass to terraform init | No | |
| terraform-validate-args | Arguments to pass to terraform validate | No | |
| terraform-plan-args | Arguments to pass to terraform plan | No | |
| terraform-show-args | Arguments to pass to terraform show | No | -no-color |
| terraform-apply-args | Arguments to pass to terraform apply | No | |
| terraform-destroy-args | Arguments to pass to terraform destroy | No | |
| terraform-plan-file | Path to Terraform plan file | No | out.tfplan |
| temp-file | Path to preview comment file | No | tmp.txt |
| setup | Setup Terramate and Terraform | No | true |
| init | Initialize Terraform | No | true |
| lint | Run linting | No | true |
| generate | Generate code | No | true |
| validate | Validate Terraform | No | true |
| plan | Plan Terraform | No | true |
| apply | Apply Terraform | No | false |
| destroy | Destroy Terraform | No | false |
| comment-pull-request | Comment on pull requests | No | true |
| github-token | GitHub token required for commenting on pull requests | No | |
| cleanup | Cleanup temporary files | No | true |
| Input Variable | Description | Required | Default Value |
| ---------------------------- | ----------------------------------------------------- | -------- | ------------- |
| terramate-version | The version of Terramate to use | No | latest |
| terraform-version | The version of Terraform to use | No | latest |
| terramate-args | Arguments to pass to each Terramate command | No | --changed |
| terramate-plan-args | Arguments to pass to Terramate in the plan step | No | |
| terramate-apply-args | Arguments to pass to Terramate in the apply step | No | |
| terramate-destroy-args | Arguments to pass to Terramate in the destroy step | No | --reverse |
| terraform-common-args | Arguments to pass to each Terraform command | No | |
| terraform-init-args | Arguments to pass to terraform init | No | |
| terraform-validate-args | Arguments to pass to terraform validate | No | |
| terraform-plan-args | Arguments to pass to terraform plan | No | |
| terraform-show-args | Arguments to pass to terraform show | No | -no-color |
| terraform-apply-args | Arguments to pass to terraform apply | No | |
| terraform-destroy-args | Arguments to pass to terraform destroy | No | |
| terraform-plan-file | Path to Terraform plan file | No | out.tfplan |
| temp-file | Path to preview comment file | No | tmp.txt |
| setup | Setup Terramate and Terraform | No | true |
| init | Initialize Terraform | No | true |
| lint | Run linting | No | true |
| generate | Generate code | No | true |
| validate | Validate Terraform | No | true |
| plan | Plan Terraform | No | true |
| apply | Apply Terraform | No | false |
| destroy | Destroy Terraform | No | false |
| comment-pull-request | Comment on pull requests | No | true |
| github-token | GitHub token required for commenting on pull requests | No | |
| cleanup | Cleanup temporary files | No | true |

>Note: The `github-token` is not marked as required but it is required when the workflow was triggered by a pull request and commenting on pull requests is enabled.

Expand Down
42 changes: 17 additions & 25 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,6 @@ name: "Terramate All-In-One"
description: "Run common terramate commands in a single GitHub action"

inputs:
go-version:
description: "The version of Go to use"
required: false
default: "latest"
terramate-version:
description: "The version of Terramate to use"
required: false
Expand Down Expand Up @@ -115,16 +111,12 @@ inputs:
runs:
using: "composite"
steps:
- name: Setup Go
if: ${{ inputs.setup == 'true' }}
uses: actions/setup-go@v5
with:
cache: false
- name: Setup Terramate
uses: terramate-io/terramate-action@v2
if: ${{ inputs.setup == 'true' }}
run: |
go install github.com/terramate-io/terramate/cmd/...@${{ inputs.terramate-version }}
shell: bash
with:
version: ${{ inputs.terramate-version }}
use_wrapper: false
- name: Setup Terraform
if: ${{ inputs.setup == 'true' }}
uses: hashicorp/setup-terraform@v3
Expand Down Expand Up @@ -168,11 +160,11 @@ runs:
shell: bash
- name: Plan
if: >-
${{
${{
( inputs.plan == 'true' ||
( inputs.comment-pull-request == 'true' &&
( inputs.comment-pull-request == 'true' &&
github.event_name == 'pull_request' )
) &&
) &&
steps.list.outputs.stdout != '' }}
run: |
terramate run \
Expand All @@ -185,8 +177,8 @@ runs:
shell: bash
- name: Generate Preview Comment
if: >-
${{
inputs.comment-pull-request == 'true' &&
${{
inputs.comment-pull-request == 'true' &&
github.event_name == 'pull_request'
}}
run: |
Expand Down Expand Up @@ -217,8 +209,8 @@ runs:
shell: bash
- name: Publish Plans
if: >-
${{
inputs.comment-pull-request == 'true' &&
${{
inputs.comment-pull-request == 'true' &&
github.event_name == 'pull_request'
}}
uses: marocchino/sticky-pull-request-comment@v2
Expand All @@ -228,14 +220,14 @@ runs:
path: ${{ inputs.temp-file }}
- name: Apply
if: >-
${{
inputs.apply == 'true' &&
${{
inputs.apply == 'true' &&
steps.list.outputs.stdout != ''
}}
run: |
if [ -f "${{ inputs.terraform-plan-file }}" ]; then
terramate run \
${{ inputs.terramate-args }} \
${{ inputs.terramate-args }} \
${{ inputs.terramate-apply-args }} \
-- terraform apply \
-auto-approve \
Expand All @@ -256,9 +248,9 @@ runs:
shell: bash
- name: Destroy
if: >-
${{
inputs.destroy == 'true' &&
steps.list.outputs.stdout != ''
${{
inputs.destroy == 'true' &&
steps.list.outputs.stdout != ''
}}
run: |
terramate run \
Expand Down
4 changes: 2 additions & 2 deletions terramate.tm.hcl
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
terramate {
required_version = "~> 0.4.0"
required_version = "~> 0.4"

config {
git {
Expand All @@ -10,4 +10,4 @@ terramate {
check_remote = true
}
}
}
}

0 comments on commit a7dcfd2

Please sign in to comment.