Working dir tweak.
This commit is contained in:
+15
-10
@@ -1,20 +1,25 @@
|
||||
#!/usr/bin/env bash
|
||||
set -e
|
||||
|
||||
# Add OpenTofu binary to PATH
|
||||
export PATH="${PATH}:/home/runner/.opentofu/bin"
|
||||
|
||||
##################
|
||||
# Inputs
|
||||
##################
|
||||
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
|
||||
WORKING_DIR="$4"
|
||||
# Read inputs
|
||||
COMMAND=$1
|
||||
INPUT=$2
|
||||
EXIT_CODE=$3
|
||||
WORKING_DIR=$4
|
||||
|
||||
# Change to working directory if provided
|
||||
# Determine repo root (where .git exists)
|
||||
REPO_ROOT=$(git rev-parse --show-toplevel 2>/dev/null || echo "$PWD")
|
||||
|
||||
# Change to working directory if provided, relative to repo root
|
||||
if [[ -n "$WORKING_DIR" ]]; then
|
||||
echo "Switching to working directory: $WORKING_DIR"
|
||||
cd "$WORKING_DIR" || { echo "Directory $WORKING_DIR not found"; exit 1; }
|
||||
TARGET_DIR="$REPO_ROOT/$WORKING_DIR"
|
||||
echo "Switching to working directory: $TARGET_DIR"
|
||||
cd "$TARGET_DIR" || { echo "Directory $TARGET_DIR not found"; exit 1; }
|
||||
else
|
||||
cd "$REPO_ROOT" || { echo "Cannot determine repo root"; exit 1; }
|
||||
fi
|
||||
|
||||
# Strip ANSI codes from input
|
||||
|
||||
Reference in New Issue
Block a user