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 update removes the wrong comment #23

Open
marcellovictorino opened this issue Nov 8, 2021 · 2 comments
Open

Comment update removes the wrong comment #23

marcellovictorino opened this issue Nov 8, 2021 · 2 comments

Comments

@marcellovictorino
Copy link

This is a great action. Thanks for sharing!

In order to provide a bit more context when running on multiple working directories and environments, I've been using a workaround. Injecting the values of interest into the TF_WORKSPACE env variable.

Which works 👍

- name: >
    Post Plan >> Env: ${{ matrix.project.env }} | Dir: ${{ matrix.project.dir }}
  if: always() && github.ref != 'refs/heads/master' && (steps.plan.outcome == 'success' || steps.plan.outcome == 'failure')
  uses: robburger/terraform-pr-commenter@v1
  env:
    TF_WORKSPACE: ${{ format('Env= {0} | Dir= {1}', matrix.project.env, matrix.project.dir) }}
  with:
    commenter_type: plan
    commenter_input: ${{ format('{0}{1}', steps.plan.outputs.stdout, steps.plan.outputs.stderr) }}
    commenter_exitcode: ${{ steps.plan.outputs.exitcode }}

image


But I noticed that, sometimes, the action incorrectly identifies an "already existing" comment and decides to update it.
For example, I have 9 different working-directories / env. But only get 5 PR comments

@robburger Any ideas?
How exactly is the "uniqueness" of a comment defined?
I imagined that, by adding more detail to the TF_WORKSPACE, it would make it more accurate.

@JensRantil
Copy link

If you search for the WORKSPACE variable in the script, you can see where it's being used. One thing to notice is that the variable is only used for commenter_type=="plan". This means your workaround will not work for init nor validate.

How exactly is the "uniqueness" of a comment defined?

Have a look at this line. In essence, it filters out the comment containing the string

"### Terraform `plan` .* for Workspace: `'"$WORKSPACE"'`"

@JensRantil
Copy link

This issue is related to #17.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants