Skip to content

Commit

Permalink
ci: fix step conditionals in terraform workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
seantrane committed Apr 18, 2023
1 parent c67483e commit 6be2c58
Showing 1 changed file with 8 additions and 9 deletions.
17 changes: 8 additions & 9 deletions .github/workflows/terraform.yml
Original file line number Diff line number Diff line change
Expand Up @@ -64,21 +64,21 @@ jobs:
ssh-private-key: ${{ secrets.SSH_PRIVATE_KEY }}

- name: Setup Terraform
if: ${{ inputs.state == 'local' || inputs.state == 's3' }}
if: inputs.state == 'local' || inputs.state == 's3'
uses: hashicorp/setup-terraform@v2
with:
terraform_version: ${{ inputs.version }}

- name: Setup Terraform Cloud
if: ${{ inputs.state == 'cloud' }}
if: inputs.state == 'cloud'
uses: hashicorp/setup-terraform@v2
with:
terraform_version: ${{ inputs.version }}
cli_config_credentials_token: ${{ secrets.TF_API_TOKEN }}

- name: Terraform Format
id: fmt
if: ${{ inputs.format == true }}
if: inputs.format == 'true'
run: terraform fmt -check

- name: Terraform Init
Expand All @@ -87,12 +87,12 @@ jobs:

- name: Terraform Validate
id: validate
if: ${{ inputs.validate == true }}
if: inputs.validate == 'true'
run: terraform validate -no-color

- name: Terraform Validation Output Summary
id: validation_summary
if: ${{ inputs.validate == true }}
if: inputs.validate == 'true'
run: |
echo "### Terraform Format and Style 🖌\`${{ steps.fmt.outcome }}\`" >> $GITHUB_STEP_SUMMARY
echo "### Terraform Initialization ⚙️\`${{ steps.init.outcome }}\`" >> $GITHUB_STEP_SUMMARY
Expand All @@ -105,19 +105,18 @@ jobs:
- name: Terraform Plan
id: plan
# if: github.event_name == 'pull_request'
if: ${{ inputs.plan == true }}
if: inputs.plan == 'true'
run: terraform plan -no-color -input=false
continue-on-error: true

- name: Terraform Plan Output Summary
id: plan_summary
if: ${{ inputs.plan == true }}
if: inputs.plan == 'true'
run: |
echo "### Terraform Plan 📖\`${{ steps.plan.outcome }}\`" >> $GITHUB_STEP_SUMMARY
echo "\`\`\`" >> $GITHUB_STEP_SUMMARY
echo "${{ steps.plan.outputs.stdout }}" >> $GITHUB_STEP_SUMMARY
echo "\`\`\`" >> $GITHUB_STEP_SUMMARY
echo "event_name: ${{ github.event_name }}" >> $GITHUB_STEP_SUMMARY
continue-on-error: true

- name: Update Pull Request
Expand Down Expand Up @@ -185,5 +184,5 @@ jobs:

- name: Terraform Apply
# if: github.ref == 'refs/heads/main' && github.event_name == 'push'
if: ${{ inputs.apply == true }}
if: inputs.apply == 'true'
run: terraform apply -auto-approve -input=false

0 comments on commit 6be2c58

Please sign in to comment.