From 471d84215cc8ca1616e905737f1b210dda69019f Mon Sep 17 00:00:00 2001 From: "Trez.One" Date: Sat, 8 Nov 2025 08:29:51 -0500 Subject: [PATCH] ... --- action.yml | 20 ++++++++++++-------- tf-pr-comment.sh | 6 ++++++ 2 files changed, 18 insertions(+), 8 deletions(-) diff --git a/action.yml b/action.yml index 5afd42a..34584e5 100644 --- a/action.yml +++ b/action.yml @@ -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 }} diff --git a/tf-pr-comment.sh b/tf-pr-comment.sh index ebef9d0..6ea1b0b 100644 --- a/tf-pr-comment.sh +++ b/tf-pr-comment.sh @@ -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"