Skip to content

Github Actions Terraform output with github-script has symbols / ascii characters #207

Open
@jku-sr

Description

@jku-sr

Following the example setup where the outputs of Terraform Plan is added to the Pull Request as a comment. However there's all these ? type symbols that gets added in the comments.

versions:
hashicorp/setup-terraform@v2
actions/github-script@v6

my Github Actions YML File

# Generates an execution plan for Terraform
      - name: Terraform Plan
        id: plan
        run: terraform plan -input=false
      - uses: actions/github-script@v6
        if: github.event_name == 'pull_request'
        env:
          PLAN: "terraform\n${{ steps.plan.outputs.stdout }}"
        with:
          script: |
            const output = `#### Terraform Plan 📖\`${{ steps.plan.outcome }}\`
        
            <details><summary>Show Plan</summary>

            \`\`\`\n
            ${process.env.PLAN}
            \`\`\`

            </details>

            *Pushed by: @${{ github.actor }}, Action: \`${{ github.event_name }}\`*`;

            github.rest.issues.createComment({
              issue_number: context.issue.number,
              owner: context.repo.owner,
              repo: context.repo.repo,
              body: output
            })`




My condensed Output:

terraform
eastus2/providers/Microsoft.Compute/virtualMachines/vm-1]�[0m
�[0m�[1mazurerm_virtual_machine_extension.ext[0]: Refreshing state... [id=/subscriptions/redacted/resourceGroups/rg-eastus2/providers/Microsoft.Compute/virtualMachines/vm-1/extensions/customscript]�[0m


�[0m�[1m�[32mNo changes.�[0m�[1m Your infrastructure matches the configuration.�[0m
�[0mTerraform has compared your real infrastructure against your configuration
and found no differences, so no changes are needed.

`

Where do these question mark symbols come from. If I set my terraform plan to -no-color it'll remove the symbols. Is there any other work around?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions