Skip to content

Terraform show #6

Open
wants to merge 12 commits into
base: main
Choose a base branch
from
24 changes: 8 additions & 16 deletions .github/workflows/terraform_plan.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -69,49 +69,41 @@ jobs:
- name: Terraform Plan
id: plan
if: github.event_name == 'pull_request'
run: terraform plan -no-color -out=${{ vars.plan_cache }}/${{ github.sha }}
run: terraform plan -out=${{ vars.plan_cache }}/${{ github.sha }}
continue-on-error: true

- name: Terraform Plan
if: github.event_name != 'pull_request'
run: terraform plan -no-color
run: terraform plan
continue-on-error: true

- name: Terraform Show plan
if: github.event_name == 'pull_request'
run: echo ::set-output name=terraform_plan::$(terraform show ${{ vars.plan_cache }}/${{ github.sha }})
run: echo terraform_plan=$(terraform show -no-color ${{ vars.plan_cache }}/${{ github.sha }}) >> $GITHUB_ENV

- name: Post Terraform Plan to PR
- name: Post Terraform Stats to PR
uses: CSVD/gh-actions-github-script@v6
if: github.event_name == 'pull_request'
env:
PLAN: "terraform\n${{ env.terraform_plan }}"
with:
github-token: ${{ secrets.GH_TOKEN }}
script: |
const plan=${process.env.PLAN};
const output = `#### 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 Plan ID: \`${{ github.sha }}\`
#### Terraform Plan 📖\`${{ steps.plan.outcome }}\`

<details><summary>Show Plan</summary>

\`\`\`\n
${process.env.PLAN}
\`\`\`

<details><summary>Plan</summary>
${{ env.terraform_plan }}
</details>

*Pusher: @${{ github.actor }}, Action: \`${{ github.event_name }}\`, Workflow: \`${{ github.workflow }}\`*`;

github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
Expand Down
2 changes: 1 addition & 1 deletion main.tf
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
locals {
collaborators = {
naray007 = "push",
morga471 = "push",
morga471 = "pull",
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:(

lolli001 = "push",
gomez385 = "push"
}
Expand Down
Loading