Working dir tweak.
This commit is contained in:
+15
-10
@@ -1,20 +1,25 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
set -e
|
set -e
|
||||||
|
|
||||||
|
# Add OpenTofu binary to PATH
|
||||||
export PATH="${PATH}:/home/runner/.opentofu/bin"
|
export PATH="${PATH}:/home/runner/.opentofu/bin"
|
||||||
|
|
||||||
##################
|
# Read inputs
|
||||||
# Inputs
|
COMMAND=$1
|
||||||
##################
|
INPUT=$2
|
||||||
COMMAND="$1" # fmt | init | plan | validate
|
EXIT_CODE=$3
|
||||||
COMMENTER_INPUT="$2" # stdout/stderr output OR newline-separated file list (for fmt)
|
WORKING_DIR=$4
|
||||||
COMMENTER_EXITCODE="$3" # exit code from previous step
|
|
||||||
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
|
if [[ -n "$WORKING_DIR" ]]; then
|
||||||
echo "Switching to working directory: $WORKING_DIR"
|
TARGET_DIR="$REPO_ROOT/$WORKING_DIR"
|
||||||
cd "$WORKING_DIR" || { echo "Directory $WORKING_DIR not found"; exit 1; }
|
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
|
fi
|
||||||
|
|
||||||
# Strip ANSI codes from input
|
# Strip ANSI codes from input
|
||||||
|
|||||||
Reference in New Issue
Block a user