This message was deleted.
# general
b
This message was deleted.
l
Are you wanting each workflow to have its own separate comment or be combined into a single comment?
p
Separate would be ideal. Somehow visible to which workflow it relates.
l
And you want each comment to be updated each time the relevant workflow is run? Or you want new comments each time?
p
Updated, basically adjustable by the comment-action parameter
I guess what is missing, is an identifier for the comment action. By default it could use the workflow file as identifier to separate comments
l
Yeah, @crooked-daybreak-55253 if we add a
tag
attribute to the GH comment action, that passes through to the `tag` input in the compost-action do you think that would work for this?
c
Yeah adding an option tag to the comment action makes sense and would prevent the comments from overwriting each other.
l
Added a PR https://github.com/infracost/actions/pull/35/files @plain-ocean-92335 can you test if this will work for you? You can reference this branch in your workflow and use it with something like this:
Copy code
- name: Post Infracost comment
  uses: infracost/actions/comment@comment-tag # Use this branch to test this
  with:
    path: /tmp/infracost.json
    behavior: update # Create a single comment and update
    tag: <YOUR_WORKFLOW_IDENTIFIER>
c
If you want to do something nicer like put a header at the top of the comment indicating the workflow take a look at the comment action.yml: https://github.com/infracost/actions/blob/master/comment/action.yml It’s a composite action meaning it’s made of GH action steps. The bash step is a little messy because we have to handle combining breakdown outputs, but the basic idea is: 1. generate the comment text by running
infracost output --format github-comment --path <path-to-breakdown-output.json>
2. post the comment with compost In step 1 you could modify the comment to add a header or whatever.
p
will test the pr today
🙌 1
My workflow looks now like this:
Copy code
- name: Post Infracost comment
        uses: infracost/actions/comment@comment-tag
        with:
          path: /tmp/infracost.json
          tag: ${{ env.GITHUB_WORKFLOW }}
          behavior: update # Create a single comment and update it.
But I don’t see that tag is passed to action in log:
Copy code
Run infracost/actions/comment@comment-tag
  with:
    path: /tmp/infracost.json
    behavior: update
    github-token: ***
thus still same behavior in pull request
l
Looking...
Ok so passing
${{ env.GITHUB_WORKFLOW }}
is coming through blank for some reason. But this works:
Copy code
- run: echo "COMMENT_TAG=$GITHUB_WORKFLOW" >> $GITHUB_ENV

- name: Post Infracost comment
  id: infracost-comment
  uses: infracost/actions/comment@comment-tag
  with:
    path: /tmp/infracost.json
    tag: ${{ env.COMMENT_TAG }}
    behavior: update
Not sure why yet, though.
p
k, will adapt
Works now.
l
Great, I'll let you know when we merge that and release it so you can change the
@comment-tag
back to
@v1
.
p
Just to make sure. The tag is invisible in the comment, so there is no visible reference ot the workflow
l
Yeah, it uses a markdown comment.
So gets embedded like
[//]: <> (your_tag)
which won't appear.
@plain-ocean-92335 this change is in a tagged release now so you can change the 
@comment-tag
 back to 
@v1
.
🙌 1