Working dir input.
This commit is contained in:
+9
-7
@@ -2,7 +2,6 @@ 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"
|
||||
|
||||
# Define the inputs
|
||||
inputs:
|
||||
command:
|
||||
description: "The command type: fmt | init | plan | validate"
|
||||
@@ -46,9 +45,11 @@ inputs:
|
||||
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: ""
|
||||
|
||||
|
||||
# Define the action type
|
||||
runs:
|
||||
using: "composite"
|
||||
steps:
|
||||
@@ -56,9 +57,12 @@ runs:
|
||||
shell: bash
|
||||
run: |
|
||||
chmod +x ${{ github.action_path }}/tf-pr-comment.sh
|
||||
${{ github.action_path }}/tf-pr-comment.sh "${{ inputs.command }}" "${{ inputs.commenter_input }}" "${{ inputs.commenter_exitcode }}"
|
||||
${{ github.action_path }}/tf-pr-comment.sh \
|
||||
"${{ inputs.command }}" \
|
||||
"${{ inputs.commenter_input }}" \
|
||||
"${{ inputs.commenter_exitcode }}" \
|
||||
"${{ inputs.working_directory }}"
|
||||
env:
|
||||
# PR Environment Variables
|
||||
PR_NUMBER: ${{ inputs.pr_number }}
|
||||
PR_COMMENTS_URL: ${{ inputs.pr_comments_url }}
|
||||
PR_COMMENT_URI: ${{ inputs.pr_comment_uri }}
|
||||
@@ -67,7 +71,5 @@ runs:
|
||||
GITEA_ACTION: ${{ inputs.gitea_action }}
|
||||
GITEA_API_URL: ${{ inputs.gitea_api_url }}
|
||||
GITEA_REPOSITORY: ${{ inputs.gitea_repository }}
|
||||
# Optional highlighting
|
||||
HIGHLIGHT_CHANGES: ${{ inputs.highlight_changes }}
|
||||
TF_WORKSPACE: ${{ inputs.tf_workspace }}
|
||||
|
||||
|
||||
+10
-1
@@ -9,7 +9,16 @@ export PATH="${PATH}:/home/runner/.opentofu/bin"
|
||||
COMMAND="$1" # fmt | init | plan | validate
|
||||
COMMENTER_INPUT="$2" # stdout/stderr output OR newline-separated file list (for fmt)
|
||||
COMMENTER_EXITCODE="$3" # exit code from previous step
|
||||
WORKSPACE="${TF_WORKSPACE:-default}"
|
||||
WORKING_DIR="$4"
|
||||
|
||||
# Change to working directory if provided
|
||||
if [[ -n "$WORKING_DIR" ]]; then
|
||||
echo "Switching to working directory: $WORKING_DIR"
|
||||
cd "$WORKING_DIR" || { echo "Directory $WORKING_DIR not found"; exit 1; }
|
||||
fi
|
||||
|
||||
# Strip ANSI codes from input
|
||||
# INPUT=$(echo "$INPUT" | sed 's/\x1b\[[0-9;]*m//g')
|
||||
|
||||
##################
|
||||
# CI Detection
|
||||
|
||||
Reference in New Issue
Block a user