Files
tf-pr-commenter/action.yml
T
2025-11-07 20:17:49 -05:00

77 lines
2.5 KiB
YAML

name: "Terraform/OpenTofu PR Commenter"
description: "Posts Terraform/OpenTofu `fmt`, `init`, `plan`, or `validate` results as PR comments on GitHub or Gitea."
author: "Charish Patel"
inputs:
command:
description: "The command type: fmt | init | plan | validate"
required: true
commenter_input:
description: "Stdout or file list from previous Terraform/OpenTofu step"
required: true
commenter_exitcode:
description: "Exit code from previous Terraform/OpenTofu step"
required: true
pr_number:
description: "PR number"
required: false
pr_comments_url:
description: "URL for PR comments API"
required: false
pr_comment_uri:
description: "URI for individual PR comment API"
required: false
github_token:
description: "GitHub token (if running in GitHub Actions)"
required: false
gitea_token:
description: "Gitea token (if running in Gitea Actions)"
required: false
gitea_action:
description: "Set to true if running in Gitea Actions"
required: false
default: "false"
gitea_api_url:
description: "Gitea API URL"
required: false
gitea_repository:
description: "Gitea repository in format owner/repo"
required: false
highlight_changes:
description: "Set to false to disable diff highlighting"
required: false
default: "true"
tf_workspace:
description: "Terraform/OpenTofu workspace (default: 'default')"
required: false
default: default
working_directory:
description: "Optional working directory relative to repo root; if set, script runs there"
required: false
default: ""
runs:
using: "composite"
steps:
- name: Run TF/Tofu PR Commenter
shell: bash
run: |
pwd ; echo -e "${{ github.action_path }}"
chmod +x ${{ github.action_path }}/tf-pr-comment.sh
${{ github.action_path }}/tf-pr-comment.sh \
"${{ inputs.command }}" \
"${{ inputs.commenter_input }}" \
"${{ inputs.commenter_exitcode }}" \
"${{ inputs.working_directory }}"
env:
PR_NUMBER: ${{ inputs.pr_number }}
PR_COMMENTS_URL: ${{ inputs.pr_comments_url }}
PR_COMMENT_URI: ${{ inputs.pr_comment_uri }}
GITHUB_TOKEN: ${{ inputs.github_token }}
GITEA_TOKEN: ${{ inputs.gitea_token }}
GITEA_ACTION: ${{ inputs.gitea_action }}
GITEA_API_URL: ${{ inputs.gitea_api_url }}
GITEA_REPOSITORY: ${{ inputs.gitea_repository }}
HIGHLIGHT_CHANGES: ${{ inputs.highlight_changes }}
TF_WORKSPACE: ${{ inputs.tf_workspace }}