cloudposse / cloudposse/github-action-atmos-terraform-plan

Infracost summary not added to PR comment

Open
#98 1 comment 1 reaction 0 assignees View on GitHub
bug
Dominant language
HCL
Stars
8
Forks
18
PR merge metrics
No merged PRs in 30d

Description

### Describe the Bug

When `pr-comment` is set to `true` and Infracost is enabled (in atmos configuration and `infracost-api-key` is provided), the `%INFRACOST_SUMMARY%` and `%INFRACOST_DIFF%` placeholders are not replaced in the comment made in the pull request.

Note that the Infracost summary is added successfully to the GitHub action summary, so the results can still be viewed there. It is only missing from the PR comment.

From what I can tell, the PR comment is made as part of the tfcmt commands. The job step that replaces the Infracost placeholders, `Set Infracost Variables`, runs _after_ the tfcmt commands, so the Infracost variables are not available in time for tfcmt. This is a bit of an interesting problem as tfcmt is also responsible for running the plan, which is required by Infracost.

### Expected Behavior

The PR comment should match nearly/exactly 1:1 with the GitHub action summary. The `%INFRACOST_SUMMARY%` and `%INFRACOST_DIFF%` placeholders should be properly replaced.

### Steps to Reproduce

1. Ensure `integrations.github.gitops.infracost-enabled` is set to `true` in atmos configuration.
2. In the workflow, ensure `infracost-api-key` is provided and `pr-comment` is set to `true`.
3. Run the workflow (preferably with an expected change).
4. Observe the PR comment result.

### Screenshots

_No response_

### Environment

- Version `4.3.0` of this action (digest `1694fc56284f79173c36922f869933c6cb1d8b72`)

### Additional Context

_No response_

Contributor guide

Open the contributing guide

Research direction

Inspect the workflow steps around the tfcmt commands and the `Set Infracost Variables` step. Trace when `%INFRACOST_SUMMARY%` and `%INFRACOST_DIFF%` become available relative to the PR comment, then verify the workflow with Infracost enabled, `infracost-api-key` provided, and `pr-comment` set to `true`; done means the placeholders are replaced in the PR comment as they are in the GitHub Actions summary.

Written by the indexing model from the issue text.

Assessment

Tech stack
github-actions, terraform
Domain
ci-cd, devops
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.