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

DOES NOT WORK #48

Open
gruckion opened this issue Feb 21, 2023 · 9 comments
Open

DOES NOT WORK #48

gruckion opened this issue Feb 21, 2023 · 9 comments

Comments

@gruckion
Copy link

Doesn't work, I see output saying it will create a comment for the plan but nothing appears.

@StefanLobbenmeierObjego
Copy link

StefanLobbenmeierObjego commented Feb 27, 2023

Cannot confirm, works in our repo. Maybe there is something wrong with permissions in your workflow?

Edit: broken in my repo as well now, same error as #48 (comment)

@jcogilvie
Copy link

I have significantly improved this in my fork; the changes can be found in PR #30:

https://github.com/GetTerminus/terraform-pr-commenter

@bchrobot
Copy link

FWIW we're seeing this in workflow logs:

Saved the plan to: workspace.plan

To perform exactly these actions, run the following command to apply:
    terraform apply \"workspace.plan\"
" "0"
INFO: Looking for an existing plan PR comment.
Error relocating /usr/bin/curl: curl_easy_nextheader: symbol not found
Error relocating /usr/bin/curl: curl_easy_header: symbol not found
INFO: No existing plan PR comment found.
INFO: Adding plan comment to PR.
Error relocating /usr/bin/curl: curl_easy_nextheader: symbol not found
Error relocating /usr/bin/curl: curl_easy_header: symbol not found

Looks like #49 was opened to address that.

No updates to master since 2021 though so we're looking at other forks. Thanks @jcogilvie for highlighting yours.

@axdotl
Copy link

axdotl commented Apr 17, 2023

@jcogilvie Thanks for providing a fork 🙏🏼

I tried it but unfortunately it fails with

INFO: Found no tfplan.  Proceeding with input argument.
curl: (48) An unknown option was passed in to libcurl

Here is the pipeline snippet

      - name: Comment Plan
        uses: GetTerminus/terraform-pr-commenter@v2
        with:
          commenter_type: plan
          commenter_input: ${{ format('{0}{1}', steps.plan.outputs.stdout, steps.plan.outputs.stderr) }}
          commenter_exitcode: ${{ steps.plan.outputs.exitcode }}
          terraform_version: 1.3.2
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
          TF_IN_AUTOMATION: true
          TF_WORKSPACE: ${{ matrix.workspace }}

Do you've an idea what's cause the failing job?

@jcogilvie
Copy link

I'll have to update its base image. I think curl has changed out from under it.

@jcogilvie
Copy link

Okay, so the most straightforward fix is to use a newer terraform_version since that actually feeds into the image used by the commenter.

I upgraded my workflows to pass in 1.4.5 (as per #49) and it started working again.

@axdotl
Copy link

axdotl commented Apr 18, 2023

Okay, so the most straightforward fix is to use a newer terraform_version since that actually feeds into the image used by the commenter.

I upgraded my workflows to pass in 1.4.5 (as per #49) and it started working again.

That did the trick 🙏🏼

@allexiusw
Copy link

I'm getting the following result:

INFO: Found no tfplan. Proceeding with input argument.
INFO: Found 1 page(s) of comments at https://api.github.com/repos/***/tf-infrastructure/issues/3/comments?per_page=100.
INFO: Looking for an existing plan PR comment.
jq: error (at :4): Cannot index string with string "body"
INFO: No existing plan PR comment found.
INFO: Found 1 page(s) of comments at https://api.github.com/repos/***/tf-infrastructure/issues/3/comments?per_page=100.
INFO: Looking for an existing outputs PR comment.
jq: error (at :4): Cannot index string with string "body"
INFO: No existing outputs PR comment found.
INFO: Writing 1 plan comment(s)
INFO: Adding plan comment to PR.
INFO: Writing 0 outputs comment(s)

I can not see any comments in my PR,

This is how my gh action looks like:

- name: Apply Terraform
      id: plan
      env:
        ...
      run: |
        terraform init &&
        terraform plan -out workspace.plan
- name: Post Plan
      if: always() && github.ref != 'refs/heads/master'
      uses: GetTerminus/terraform-pr-commenter@v2
      with:
        commenter_type: plan
        commenter_input: ${{ format('{0}{1}', steps.plan.outputs.stdout, steps.plan.outputs.stderr) }}
        commenter_exitcode: ${{ steps.plan.outputs.exitcode }}
        terraform_version: 1.4.5
      env:
        GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
        TF_IN_AUTOMATION: true

Any ideas?

@rdhar
Copy link

rdhar commented Aug 21, 2023

Instead of a pulling a Docker-image every time, I took a stab at this in DevSecTop/TF-via-PR repository, which hosts a reusable workflow to run Terraform commands via PR comments, like a CLI.

Although it doesn't have all the bells and whistles of terraform-pr-commenter (yet), it's a fair bit quicker; runs Terraform commands simultaneously in bulk; and, dynamically handles Terraform arguments (e.g., -backend-config, -chdir, -var-file, -workspace, -destroy and -auto-approve) straight from your PR comment input.

Here's an example of the workflow in action and how the output comments are formatted.

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

7 participants