Wrap the tf plan output so it is more readable in the PR (#10)

* Wrap the tf plan output so it is more readable in the PR

* Remove extra period.

Co-authored-by: Matthew Sanabria <24284972+sudomateo@users.noreply.github.com>

Co-authored-by: Matthew Sanabria <24284972+sudomateo@users.noreply.github.com>
This commit is contained in:
chenrui 2020-05-15 13:27:42 -04:00 committed by GitHub
parent 3301b9a828
commit 813167dada
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -21,14 +21,14 @@ The default configuration installs the latest version of Terraform CLI and insta
```yaml ```yaml
steps: steps:
- uses: hashicorp/setup-terraform@v1 - uses: hashicorp/setup-terraform@v1
``` ```
A specific version of Terraform CLI can be installed. A specific version of Terraform CLI can be installed.
```yaml ```yaml
steps: steps:
- uses: hashicorp/setup-terraform@v1 - uses: hashicorp/setup-terraform@v1
with: with:
terraform_version: 0.12.25 terraform_version: 0.12.25
``` ```
@ -37,7 +37,7 @@ Credentials for Terraform Cloud (app.terraform.io) can be configured.
```yaml ```yaml
steps: steps:
- uses: hashicorp/setup-terraform@v1 - uses: hashicorp/setup-terraform@v1
with: with:
cli_config_credentials_token: ${{ secrets.TF_API_TOKEN }} cli_config_credentials_token: ${{ secrets.TF_API_TOKEN }}
``` ```
@ -46,7 +46,7 @@ Credentials for Terraform Enterprise can be configured.
```yaml ```yaml
steps: steps:
- uses: hashicorp/setup-terraform@v1 - uses: hashicorp/setup-terraform@v1
with: with:
cli_config_credentials_hostname: 'terraform.example.com' cli_config_credentials_hostname: 'terraform.example.com'
cli_config_credentials_token: ${{ secrets.TF_API_TOKEN }} cli_config_credentials_token: ${{ secrets.TF_API_TOKEN }}
@ -56,7 +56,7 @@ The wrapper script installation can be skipped.
```yaml ```yaml
steps: steps:
- uses: hashicorp/setup-terraform@v1 - uses: hashicorp/setup-terraform@v1
with: with:
terraform_wrapper: false terraform_wrapper: false
``` ```
@ -92,15 +92,17 @@ steps:
- uses: actions/github-script@0.9.0 - uses: actions/github-script@0.9.0
if: github.event_name == 'pull_request' if: github.event_name == 'pull_request'
env: env:
STDOUT: "```${{ steps.plan.outputs.stdout }}```" STDOUT: "```terraform\n${{ steps.plan.outputs.stdout }}```"
with: with:
github-token: ${{ secrets.GITHUB_TOKEN }} github-token: ${{ secrets.GITHUB_TOKEN }}
script: | script: |
const output = `<details><summary>tf plan:</summary>\n\n${process.env.STDOUT}\n\n</details>`;
github.issues.createComment({ github.issues.createComment({
issue_number: context.issue.number, issue_number: context.issue.number,
owner: context.repo.owner, owner: context.repo.owner,
repo: context.repo.repo, repo: context.repo.repo,
body: process.env.STDOUT body: output
}) })
``` ```
@ -114,17 +116,17 @@ The following inputs are supported.
- `terraform_version` - (optional) The version of Terraform CLI to install. A value of `latest` will install the latest version of Terraform CLI. Defaults to `latest`. - `terraform_version` - (optional) The version of Terraform CLI to install. A value of `latest` will install the latest version of Terraform CLI. Defaults to `latest`.
- `terraform_wrapper` - (optional) Whether or not to install a wrapper to wrap subsequent calls of the `terraform` binary and expose its STDOUT, STDERR, and exit code as outputs named `stdout`, `stderr`, and `exitcode` respectively. Defaults to `true`. - `terraform_wrapper` - (optional) Whether or not to install a wrapper to wrap subsequent calls of the `terraform` binary and expose its STDOUT, STDERR, and exit code as outputs named `stdout`, `stderr`, and `exitcode` respectively. Defaults to `true`.
## Outputs ## Outputs
This action does not configure any outputs directly. However, when the `terraform_wrapper` input is set to `true`, the following outputs will be available for subsequent steps that call the `terraform` binary. This action does not configure any outputs directly. However, when the `terraform_wrapper` input is set to `true`, the following outputs will be available for subsequent steps that call the `terraform` binary.
- `stdout` - The STDOUT stream of the call to the `terraform` binary. - `stdout` - The STDOUT stream of the call to the `terraform` binary.
- `stderr` - The STDERR stream of the call to the `terraform` binary. - `stderr` - The STDERR stream of the call to the `terraform` binary.
- `exitcode` - The exit code of the call to the `terraform` binary.. - `exitcode` - The exit code of the call to the `terraform` binary.
## License ## License