GetTerminus / terraform-pr-commenter

A GitHub Action that adds opinionated comments to a PR from Terraform fmt/init/plan output
MIT License
28 stars 16 forks source link

Error when running #25

Closed danielytics closed 11 months ago

danielytics commented 1 year ago

I'm unable to get this to run, I always get:

ERROR: There must be an exit code from a previous step.

Full output:

Run GetTerminus/terraform-pr-commenter@v3
Run if [[ -z [1](https://github.com/...?pr=1#step:13:1).4.6 ]]; then
Run docker build --build-arg TERRAFORM_VERSION=1.4.6 -t commenter https://github.com/GetTerminus/terraform-pr-commenter.git#v3
#0 building with "default" instance using docker driver

#1 [internal] load git source https://github.com/GetTerminus/terraform-pr-commenter.git#v3
#1 0.189 7f94331232e2a9c9e94c80316e6dcd683aeaf0a4   refs/tags/v3
#1 CACHED

#2 [internal] load metadata for docker.io/hashicorp/terraform:1.4.6
#2 DONE 0.1s

#3 [1/8] FROM docker.io/hashicorp/terraform:1.4.6@sha256:1ab70aa9b5dcc007d1d908c972405e2623490a51843a500682809013a4d21699
#3 DONE 0.0s

#4 [3/8] ADD entrypoint.sh /entrypoint.sh
#4 CACHED

#5 [6/8] RUN chmod +x /entrypoint.sh
#5 CACHED

#6 [2/8] RUN apk add --no-cache -q     bash     curl     perl     jq
#6 CACHED

#7 [5/8] ADD /utilities /utilities
#7 CACHED

#8 [7/8] RUN chmod +x /handlers
#8 CACHED

#9 [4/8] ADD /handlers /handlers
#9 CACHED

#10 [8/8] RUN chmod +x /utilities
#10 CACHED

#11 exporting to image
#11 exporting layers done
#11 writing image sha256:d[30](https://github.com...?pr=1#step:13:32)d5625bff6f7bb5d8fe3d088e8ed28dfdd44bd286c8404d1e169594ee8d5[42](https://github.com/...?pr=1#step:13:45) done
#11 naming to docker.io/library/commenter done
#11 DONE 0.0s
Run docker run \
ERROR: There must be an exit code from a previous step.
Error: Process completed with exit code 1.

I'm using the the workflow from the README with only minor tweaks (moving the tflint id to the correct step etc):

name: Terraform

on:
  pull_request:

env:
  GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
  TF_VERSION: "1.4.6"

jobs:
  terraform:
    name: Run Terraform and Comment
    runs-on: ubuntu-latest
    steps:
      - name: Checkout
        uses: actions/checkout@v3
      - name: HashiCorp - Setup Terraform
        uses: hashicorp/setup-terraform@v2
        with:
          terraform_version: ${{ env.TF_VERSION }}
      - name: Terraform Format
        id: fmt
        run: |
          terraform fmt -check -recursive -diff
        continue-on-error: true
      - name: Post Format Comment
        if: ${{ always() && (steps.fmt.outcome == 'success' || steps.fmt.outcome == 'failure') }}
        uses: GetTerminus/terraform-pr-commenter@v3
        with:
          commenter_type: fmt
          commenter_input: ${{ format('{0}{1}', steps.fmt.outputs.stdout, steps.fmt.outputs.stderr) }}
          commenter_exitcode: ${{ steps.fmt.outputs.exitcode }}
      - name: Terraform Init
        id: init
        run: terraform init -lock=false -input=false
      - name: Post Init Comment
        if: ${{ always() && (steps.init.outcome == 'success' || steps.init.outcome == 'failure') }}
        uses: GetTerminus/terraform-pr-commenter@v3
        with:
          commenter_type: init
          commenter_input: ${{ format('{0}{1}', steps.init.outputs.stdout, steps.init.outputs.stderr) }}
          commenter_exitcode: ${{ steps.init.outputs.exitcode }}
      - name: Terraform Validate
        id: validate
        run: terraform validate
      - name: Post TF Validate Comment
        if: ${{ always() && (steps.validate.outcome == 'success' || steps.validate.outcome == 'failure') }}
        uses: GetTerminus/terraform-pr-commenter@v3
        with:
          commenter_type: validate
          commenter_input: ${{ format('{0}{1}', steps.validate.outputs.stdout, steps.validate.outputs.stderr) }}
          commenter_exitcode: ${{ steps.validate.outputs.exitcode }}
      - name: TFLint - Setup
        uses: terraform-linters/setup-tflint@v3
        with:
          tflint_wrapper_enabled: true
      - name: TFLint - Run
        id: tflint
        run: |
          tflint --version
          tflint --init
          tflint
      - name: Post TFLint Comment
        if: ${{ always() && (steps.tflint.outcome == 'success' || steps.tflint.outcome == 'failure') }}
        uses: GetTerminus/terraform-pr-commenter@dpr-update-commenter
        with:
          commenter_type: tflint
          commenter_input: ${{ format('{0}{1}', steps.tflint.outputs.stdout, steps.tflint.outputs.stderr) }}
          commenter_exitcode: ${{ steps.tflint.outputs.exitcode }}
      - name: Terraform Plan
        id: plan
        run: terraform plan -lock=false -input=false |& tee tf_plan.txt
      - uses: GetTerminus/terraform-pr-commenter@v3
        with:
          commenter_type: plan
          commenter_plan_path: tf_plan.txt
          commenter_exitcode: ${{ steps.plan.outputs.exit }}
syerneni-sp commented 1 year ago

@danielytics update your code in the last line from: commenter_exitcode: ${{ steps.plan.outputs.exit }} to: commenter_exitcode: ${{ steps.plan.outputs.exitcode }}

I believe its a typo in the documentation and they need to update it

danielytics commented 1 year ago

Oh! I’ll give it a try, thank you!

brianzinn commented 5 months ago

@dreinhardt-terminus this issue should be open. kindly check for ${{ steps.plan.outputs.exit }} in main readme (the other steps are correct). I changed from .exit to .exitcode and it's working...