Skip to content

Update terraform command #19

Update terraform command

Update terraform command #19

Workflow file for this run

name: "Terraform Development"
on:
push:
branches-ignore:
- "main"
# paths:
# - "terraform/**"
env:
name: dev
TF_CLOUD_ORGANIZATION: "${{ vars.TF_CLOUD_ORGANIZATION }}"
TF_API_TOKEN: "${{ secrets.TF_API_TOKEN }}"
TF_WORKSPACE: "${{ vars.TF_WORKSPACE }}"
TF_WORKING_DIR: "./terraform"
PLURALITH_ORG_ID: "${{ vars.PLURALITH_ORG_ID }}"
PLURALITH_PROJECT_ID: "${{ vars.PLURALITH_PROJECT_ID }}"
permissions:
contents: write
pull-requests: write
defaults:
run:
working-directory: ./terraform
shell: bash
jobs:
terraform:
name: "Terraform Apply (Development)"
runs-on: ubuntu-latest
defaults:
run:
working-directory: ./terraform
shell: bash
environment: dev
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Terraform
id: tfc-setup
uses: hashicorp/setup-terraform@v3
with:
cli_config_credentials_token: ${{ secrets.TF_API_TOKEN }}
- name: Terraform fmt
id: fmt
run: terraform fmt -check
continue-on-error: true
- name: Terraform Init
id: init
run: terraform init
- name: Terraform Validate
id: validate
run: terraform validate -no-color
# - name: Terraform Apply
# id: apply
# run: terraform apply -no-color -input=false -auto-approve
# continue-on-error: true
# Set up and authenticate Pluralith
- name: Pluralith Init
# uses: Pluralith/actions/[email protected]
uses: Just-Insane/pluralith-actions/init@e5d17b2206d59f65419079e2c51db6b9096ddcfd
with:
terraform-path: "${{ env.TF_WORKING_DIR }}"
api-key: "${{ secrets.PLURALITH_API_KEY }}"
org-id: "${{ vars.PLURALITH_ORG_ID }}"
project-id: "${{ vars.PLURALITH_PROJECT_ID }}"
- name: Pluralith Run Apply
id: apply
# uses: Pluralith/actions/[email protected]
uses: Just-Insane/pluralith-actions/run@e5d17b2206d59f65419079e2c51db6b9096ddcfd
with:
terraform-command: "apply -no-color -input=false -auto-approve"
terraform-path: "${{ env.TF_WORKING_DIR }}"
title: "${{ env.name }}"
show-changes: true
show-drift: true
show-costs: false
- name: Pluralith Comment
id: comment
uses: Just-Insane/pluralith-actions/comment@e5d17b2206d59f65419079e2c51db6b9096ddcfd
with:
terraform-path: "${{ env.TF_WORKING_DIR }}"
target-type: commit
- name: truncate terraform apply result
run: |
apply=$(cat <<'EOF'
${{ format('{0}{1}', steps.apply.outputs.stdout, steps.apply.outputs.stderr) }}
EOF
)
echo "APPLY<<EOF" >> $GITHUB_ENV
echo "${apply:0:65536}" >> $GITHUB_ENV
echo "EOF" >> $GITHUB_ENV
- name: Create commit comment
uses: peter-evans/commit-comment@v3
id: cc
# env:
# APPLY: "terraform\n${{ steps.apply.outputs.stdout }}"
with:
body: |
#### Terraform Format and Style 🖌\`${{ steps.fmt.outcome }}\`
#### Terraform Initialization ⚙️\`${{ steps.init.outcome }}\`
#### Terraform Validation 🤖\`${{ steps.validate.outcome }}\`
<details><summary>Validation Output</summary>
```\n
${{ steps.validate.outputs.stdout }}
```
</details>
#### Terraform Apply 📖\`${{ steps.apply.outcome }}\`
<details><summary>Show Apply</summary>
```\n
${{ env.APPLY }}
```
</details>
#### Pluralith Graph
<details><summary>Show Graph</summary>
${{ steps.comment.outputs.body }}
</details>
*Pusher: @${{ github.actor }}, Action: \`${{ github.event_name }}\`, Working Directory: \`${{ env.TF_WORKING_DIR }}\`, Workflow: \`${{ github.workflow }}\`*`;
- name: Check outputs
run: |
echo "Comment ID - ${{ steps.cc.outputs.comment-id }}"