infracost/actions

post_condition seems to have disapeared from new GH Action

Closed this issue · 2 comments

In the previous github action, there were several options to post infracost comments in PR only under conditions, with the post_condition JSON string

  • has_diff
  • percentage_threshold

This was really useful to post comments only when necessary, and avoid adding noise in the pull requests.

As these options seem to have disappeared, is there an alternative?

Hey @glebourgeois,

Thanks for raising this issue. So the has_diff functionality has been replaced by the Infracost comment --behavior=update flag. This only updates a PR comment if there is a change in costs.

Regarding the percentage_threshold, we have removed this option in favour of a more flexible approach, allowing users to define the specifics of how they want their comments posted. Infracost integrates with cost policy engines like sentinel and OPA. You can check out our sentinel example here and read more about our native integration with OPA here.

If you're looking for a native bash/actions way to post a comment conditionally, you can always pick values out of our output. I'd recommend looking at this issue: infracost/infracost#1472 for more information.

I will close this issue but feel free to ping me if you have further questions.

@glebourgeois In case it helps, here is a link to an example that performs the percentage_threshold behavior using a actions/github-script (javascript). This was removed from the docs to simplify things, but the basic idea is to perform some calculation then use the GitHub actions if expression to decide whether or not to run comment.