Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 24 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -108,16 +108,23 @@ steps:

- name: Terraform Plan
id: plan
run: terraform plan -no-color
run: |
Copy link

Choose a reason for hiding this comment

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

Suggested change
run: |
run: terraform plan -no-color | tee plan.out

terraform plan -no-color > plan.out
cat plan.out
continue-on-error: true

- uses: actions/github-script@v7
if: github.event_name == 'pull_request'
env:
PLAN: "terraform\n${{ steps.plan.outputs.stdout }}"
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const fs = require('node:fs');
const data = fs.readFileSync('terraform/plan.out', 'utf8');
const plan = "terraform\n" + data.length > 65000 ? `${data.substring(data.length - 65000)}...` : data
let truncated = '';
if (data.length > 65000) {
truncated = 'plan was truncated, view the <a href="${{ github.server_url}}/${{ github.repository }}/actions/runs/${{ github.run_id }}">job log</a> for the full plan';
}
const output = `#### Terraform Format and Style 🖌\`${{ steps.fmt.outcome }}\`
#### Terraform Initialization ⚙️\`${{ steps.init.outcome }}\`
#### Terraform Validation 🤖\`${{ steps.validate.outcome }}\`
Expand All @@ -134,10 +141,11 @@ steps:
<details><summary>Show Plan</summary>

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

</details>
${truncated}

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

Expand Down Expand Up @@ -176,16 +184,23 @@ steps:

- name: Terraform Plan
id: plan
run: terraform plan -no-color
run: |
terraform plan -no-color > plan.out
cat plan.out
continue-on-error: true

- uses: actions/github-script@v7
if: github.event_name == 'pull_request'
env:
PLAN: "terraform\n${{ steps.plan.outputs.stdout }}"
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const fs = require('node:fs');
const data = fs.readFileSync('terraform/plan.out', 'utf8');
const plan = "terraform\n" + data.length > 65000 ? `${data.substring(data.length - 65000)}...` : data
let truncated = '';
if (data.length > 65000) {
truncated = 'plan was truncated, view the <a href="${{ github.server_url}}/${{ github.repository }}/actions/runs/${{ github.run_id }}">job log</a> for the full plan';
}
// 1. Retrieve existing bot comments for the PR
const { data: comments } = await github.rest.issues.listComments({
owner: context.repo.owner,
Expand Down Expand Up @@ -213,10 +228,11 @@ steps:
<details><summary>Show Plan</summary>

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

</details>
${truncated}

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

Expand Down