Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

comment subcommand to post to VCS like github #14

Open
nitrocode opened this issue Oct 26, 2022 · 3 comments
Open

comment subcommand to post to VCS like github #14

nitrocode opened this issue Oct 26, 2022 · 3 comments
Labels
enhancement New feature or request

Comments

@nitrocode
Copy link

nitrocode commented Oct 26, 2022

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.

https://github.com/infracost/infracost-atlantis/blob/master/examples/combined-infracost-comment/README.md

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.

https://github.com/cloudposse/github-commenter/

@dineshba
Copy link
Owner

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:

  1. We can update readme about this easy integration (after testing it out)
  2. We can have one sample github action workflow for easily trying it out

@dineshba dineshba added enhancement New feature or request question Further information is requested labels Oct 26, 2022
@dineshba
Copy link
Owner

I used another workflow to comment the summary in the PR https://github.com/dineshba/tf-summarize#comment-terraform-plan-summary-in-prs

@nitrocode
Copy link
Author

That's handy if the terraform workflows are in github actions but I don't think that method would work from an atlantis workflow

@dineshba dineshba removed the question Further information is requested label Dec 2, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants