ci(#8): Switch to fork #9
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
name: "Terraform" | ||
on: | ||
pull_request: | ||
env: | ||
TF_IN_AUTOMATION: true | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
TF_VAR_gh_token: ${{ secrets.GITHUB_TOKEN }} | ||
TF_VAR_billing_email: ${{ secrets.TF_VAR_billing_email }} | ||
jobs: | ||
terraform: | ||
name: Run Terraform and Comment | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: HashiCorp - Setup Terraform | ||
uses: hashicorp/setup-terraform@v2 | ||
with: | ||
terraform_version: ${{ env.TF_VERSION }} | ||
- name: Terraform Format | ||
id: fmt | ||
run: | | ||
terraform fmt -check -recursive -diff | ||
continue-on-error: true | ||
- name: Post Format Comment | ||
if: ${{ always() && (steps.fmt.outcome == 'success' || steps.fmt.outcome == 'failure') }} | ||
uses: GetTerminus/terraform-pr-commenter@v3 | ||
with: | ||
commenter_type: fmt | ||
commenter_input: ${{ format('{0}{1}', steps.fmt.outputs.stdout, steps.fmt.outputs.stderr) }} | ||
commenter_exitcode: ${{ steps.fmt.outputs.exitcode }} | ||
- name: Terraform Init | ||
id: init | ||
run: terraform init -lock=false -input=false | ||
- name: Post Init Comment | ||
if: ${{ always() && (steps.init.outcome == 'success' || steps.init.outcome == 'failure') }} | ||
uses: GetTerminus/terraform-pr-commenter@v3 | ||
with: | ||
commenter_type: init | ||
commenter_input: ${{ format('{0}{1}', steps.init.outputs.stdout, steps.init.outputs.stderr) }} | ||
commenter_exitcode: ${{ steps.init.outputs.exitcode }} | ||
- name: Terraform Validate | ||
id: validate | ||
run: terraform validate | ||
- name: Post TF Validate Comment | ||
if: ${{ always() && (steps.validate.outcome == 'success' || steps.validate.outcome == 'failure') }} | ||
uses: GetTerminus/terraform-pr-commenter@v3 | ||
with: | ||
commenter_type: validate | ||
commenter_input: ${{ format('{0}{1}', steps.validate.outputs.stdout, steps.validate.outputs.stderr) }} | ||
commenter_exitcode: ${{ steps.validate.outputs.exitcode }} | ||
- name: TFLint - Setup | ||
id: tflint | ||
uses: terraform-linters/setup-tflint@v3 | ||
with: | ||
tflint_wrapper_enabled: true | ||
- name: TFLint - Run | ||
run: | | ||
tflint --version | ||
tflint --init | ||
tflint | ||
- name: Post TFLint Comment | ||
if: ${{ always() && (steps.tflint.outcome == 'success' || steps.tflint.outcome == 'failure') }} | ||
uses: GetTerminus/terraform-pr-commenter@dpr-update-commenter | ||
with: | ||
commenter_type: tflint | ||
commenter_input: ${{ format('{0}{1}', steps.tflint.outputs.stdout, steps.tflint.outputs.stderr) }} | ||
commenter_exitcode: ${{ steps.tflint.outputs.exitcode }} | ||
- name: Terraform Plan | ||
id: plan | ||
run: terraform plan -lock=false -input=false |& tee tf_plan.txt | ||
- uses: GetTerminus/terraform-pr-commenter@v3 | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
TF_WORKSPACE: ${{ inputs.terraform_workspace }} | ||
with: | ||
commenter_type: plan | ||
commenter_plan_path: tf_plan.txt | ||
commenter_exitcode: ${{ steps.plan.outputs.exit }} |