diff --git a/.github/workflows/test-and-release.yml b/.github/workflows/test-and-release.yml index 71b9bde..05381b0 100644 --- a/.github/workflows/test-and-release.yml +++ b/.github/workflows/test-and-release.yml @@ -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"] @@ -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 }} diff --git a/README.md b/README.md index 079e566..fabec46 100644 --- a/README.md +++ b/README.md @@ -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. diff --git a/action.yml b/action.yml index 2eac6fc..2fd0180 100644 --- a/action.yml +++ b/action.yml @@ -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 @@ -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 @@ -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 \ @@ -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: | @@ -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 @@ -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 \ @@ -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 \ diff --git a/terramate.tm.hcl b/terramate.tm.hcl index 563c4a7..ec2b3df 100644 --- a/terramate.tm.hcl +++ b/terramate.tm.hcl @@ -1,5 +1,5 @@ terramate { - required_version = "~> 0.4.0" + required_version = "~> 0.4" config { git { @@ -10,4 +10,4 @@ terramate { check_remote = true } } -} \ No newline at end of file +}