Pluralith / actions

A collection of GitHub Actions to run Pluralith in CI and automate infrastructure documentation generation
Mozilla Public License 2.0
26 stars 3 forks source link

Error: body-file ./terraform/comment.md does not exist #14

Open DonggeunYu opened 1 year ago

DonggeunYu commented 1 year ago

I used the following yaml. But I get an error not finding the comment.md file.

  pluralith:
    runs-on: ubuntu-latest
    permissions:
      contents: read
      pull-requests: write
    env:
      working-directory: ./terraform
    steps:
      - name: Check out repository
        uses: actions/checkout@v3
        with:
          ref: ${{ github.event.pull_request.head.ref }}

      # Set up Terraform
      - name: Setup Terraform
        uses: hashicorp/setup-terraform@v1
        with:
          terraform_wrapper: false # This is recommended so the `terraform show` command outputs valid JSON
        env:
          GOOGLE_CREDENTIALS: ${{ secrets.GOOGLE_CREDENTIALS_DEV }}

      # Init Terraform project
      - name: Terraform Init
        run: terraform init
        working-directory: ${{ env.working-directory }}
        env:
          GOOGLE_CREDENTIALS: ${{ secrets.GOOGLE_CREDENTIALS_DEV }}

      - name: Setup Infracost
        uses: infracost/actions/setup@v2
        # See https://github.com/infracost/actions/tree/master/setup for other inputs
        # If you can't use this action, see Docker images in https://infracost.io/cicd
        with:
          api-key: ${{ secrets.INFRACOST_API_KEY }}

      # Set up and authenticate Pluralith
      - name: Pluralith Init
        uses: Pluralith/actions/init@v1.3.0
        with:
          terraform-path: ${{ env.working-directory }}
          api-key: ${{ secrets.PLURALITH_API_KEY }}
          project-id: ${{ secrets.PLURALITH_PROJECT_ID }}
        env:
          GOOGLE_CREDENTIALS: ${{ secrets.GOOGLE_CREDENTIALS_DEV }}

      # Run Pluralith to generate an infrastructure diagram and comment body
      - name: Pluralith Run
        uses: Pluralith/actions/run@v1.3.0
        with:
          title: \#${{ github.event.number }}
          terraform-command: "plan"
          terraform-path: ${{ env.working-directory }}
          show-changes: true
          show-drift: true
          show-costs: true # Requires Infracost to be set up in your pipeline
        env:
          GOOGLE_CREDENTIALS: ${{ secrets.GOOGLE_CREDENTIALS_DEV }}

      # Post the generated diagram as a GitHub comment
      - name: Pluralith Comment
        uses: Pluralith/actions/comment@v1.3.0
        with:
          terraform-path: ${{ env.working-directory }}
          behavior: hide-and-new
        env:
          GOOGLE_CREDENTIALS: ${{ secrets.GOOGLE_CREDENTIALS_DEV }}

Error:

Error: Error: body-file ./terraform/comment.md does not exist
DilanAriza commented 1 year ago

I have the same problem with a similar configuration... we hope you help us with this problem. @DanThePutzer

DanThePutzer commented 1 year ago

@DilanAriza thanks for reporting!

We've seen this issue before, usually it happens because the step before the comment step fails, but is marked as successful anyway.

Could you check in your action what the output for the step before the failing one says? It could say something like "No org ID given" or something like that. Let me know if that is the case and I can help fix it!