This commit is contained in:
2025-11-08 08:29:51 -05:00
parent 13ee7a84e1
commit 471d84215c
2 changed files with 18 additions and 8 deletions
+12 -8
View File
@@ -7,17 +7,22 @@ branding:
inputs:
commenter_type:
description: "The Terraform/OpenTofu command type (e.g., init, plan, fmt, validate)"
description: "Type of command (init, fmt, validate, plan)"
required: true
commenter_input:
description: "Captured stdout/stderr output of the Terraform/OpenTofu command"
description: "Output from the command (e.g. plan output)"
required: true
commenter_exitcode:
description: "Exit code of the Terraform/OpenTofu command"
description: "Exit code of the command"
required: true
working_dir:
description: "Optional working directory relative to the repository root (e.g., cloudflare)"
default: "0"
working_directory:
description: "Optional working directory (relative to repo root)"
required: false
github_token:
description: "Token used for posting the comment (Gitea or GitHub)"
required: true
@@ -28,12 +33,11 @@ runs:
- name: Run Terraform/OpenTofu PR Commenter
shell: bash
run: |
chmod +x "${{ github.action_path }}/tf-pr-comment.sh"
"${{ github.action_path }}/tf-pr-comment.sh" \
bash "${GITHUB_ACTION_PATH}/tf-pr-comment.sh" \
"${{ inputs.commenter_type }}" \
"${{ inputs.commenter_input }}" \
"${{ inputs.commenter_exitcode }}" \
"${{ inputs.working_dir }}"
"${{ inputs.working_directory }}"
env:
GITHUB_TOKEN: ${{ inputs.github_token }}
PR_NUMBER: ${{ env.PR_NUMBER }}
+6
View File
@@ -7,6 +7,12 @@ COMMENTER_INPUT="${2:-}"
COMMENTER_EXITCODE="${3:-0}"
WORKING_DIR="${4:-}"
# If WORKING_DIR is numeric (likely passed exitcode by mistake), reset it
if [[ "$WORKING_DIR" =~ ^[0-9]+$ ]]; then
echo "⚠️ Detected numeric working_dir ('$WORKING_DIR'); treating as unset."
WORKING_DIR=""
fi
# === Move into working directory if specified ========================
if [[ -n "$WORKING_DIR" ]]; then
echo "🔹 Changing to working directory: $WORKING_DIR"