comment subcommand to post to VCS like github
Opened this issue · 3 comments
Hi. I like your command line utility a lot.
I use atlantis for gh terraform workflows and I would love to integrate this app with atlantis similar to infracosts latest setup.
Excerpt from above
# Choose the commenting behavior, 'new' is a good default:
# new: Create a new cost estimate comment on every run of Atlantis for each project.
# update: Create a single comment and update it. The "quietest" option.
# hide-and-new: Minimize previous comments and create a new one.
# delete-and-new: Delete previous comments and create a new one.
infracost comment github --repo $BASE_REPO_OWNER/$BASE_REPO_NAME \
--pull-request $PULL_NUM \
--path /tmp/$BASE_REPO_OWNER-$BASE_REPO_NAME-$PULL_NUM/'*'-infracost.json \
--github-token $GITHUB_TOKEN \
--behavior new
It would be awesome if tf-summarize could follow the same spec so it can be integrated the same way 😄
Infracost is also a golang lib and I'd be curious if its libraries could be reused to support the gh commenter (and maybe even the other VCSs)
https://github.com/infracost/infracost
Actually, after some additional research it looks like infracost put a lot of its comment logic in its internal subdirectory making it impossible to use as a library.
I did come across this command line utility that could be used instead of building a subcommand.
Hi @nitrocode Thanks for the issue. I agree, we can use https://github.com/cloudposse/github-commenter/ for adding comments to PR.
Like:
tf-summarize -tree tfplan | github-commenter -format "Output from `terraform plan summary:`<br/>```{{.}}```"
I assume there is not code change in tf-summarize for it. Please correct me if my understanding is wrong.
Next steps:
- We can update readme about this easy integration (after testing it out)
- We can have one sample github action workflow for easily trying it out
I used another workflow to comment the summary in the PR https://github.com/dineshba/tf-summarize#comment-terraform-plan-summary-in-prs
That's handy if the terraform workflows are in github actions but I don't think that method would work from an atlantis workflow