Skip to content

Commit

Permalink
feat: Add feature, comment on pr is optional with new input and outpu…
Browse files Browse the repository at this point in the history
…t to file essential_output_file is added
  • Loading branch information
Hein Tonny Køien committed Nov 7, 2023
1 parent 3940e43 commit e45c257
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 4 deletions.
15 changes: 12 additions & 3 deletions action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,19 @@ inputs:
output_file:
description: 'Path to the Terraform plan output file'
required: true
comment_on_pull_request:
description: 'Whether to comment on the Pull Request or not'
required: false
default: "true"
essential_output_file:
description: 'Name to the essential Terraform plan output file'
required: false
outputs:
essential-plan-output:
runs:
using: 'composite'
steps:
- run: chmod +x ${{ github.action_path }}/src/main.sh
shell: bash
- run: ${{ github.action_path }}/src/main.sh "${{ inputs.output_file }}"
- name: Run
id: run
run: ${{ github.action_path }}/src/main.sh "${{ inputs.output_file }}"
shell: bash
9 changes: 8 additions & 1 deletion src/main.sh
Original file line number Diff line number Diff line change
Expand Up @@ -39,5 +39,12 @@ if [[ -z $clean_essential_output ]]; then
comment_on_pr "Terraform essential output is empty. Please check the plan output."
else
comment_body=$(printf "## Terraform Plan Essential Output\n\`\`\`\n%s\n\`\`\`\n" "$clean_essential_output")
comment_on_pr "$comment_body"
if [[ $comment_on_pull_request == "true" ]]; then
# Comment on the PR
comment_on_pr "$comment_body"
fi
if [[ $essential_output_file != "" ]]; then
# Save the essential output to a file
echo "$comment_body" > "$essential_output_file"
fi
fi

0 comments on commit e45c257

Please sign in to comment.