Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion .github/opentofu-validate.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,19 @@ if [[ "true" == "$CI" ]]; then
$INSTALL_COMMAND || $SUDO $INSTALL_COMMAND
fi
fi
else
CI=false
fi
set -u

export IAC_BIN=tofu

$IAC_BIN version

for WORKSPACE in $(find . \( -name '*.tf' -o -name '*.otf' \) -not -path '*/docs/*/example/*' -print0 | xargs -0 -I{} dirname {} | sort -u); do
for WORKSPACE in $(find . \( -name '*.tf' -o -name '*.otf' \) -not -path '*/.terraform/*' -not -path '*/docs/*/example/*' -print0 | xargs -0 -I{} dirname {} | sort -u); do
bash -e .github/tf.sh "$WORKSPACE" validate
if [[ "true" == "$CI" ]]; then
# Git will refuse to modify untracked nested git repositories (directories with a .git subdirectory) unless a second -f is given.
git clean -ffxd .
fi
done
8 changes: 7 additions & 1 deletion .github/terraform-validate.sh
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,19 @@ if [[ "true" == "$CI" ]]; then
$INSTALL_COMMAND || $SUDO $INSTALL_COMMAND
fi
fi
else
CI=false
fi
set -u

export IAC_BIN=terraform

$IAC_BIN version

for WORKSPACE in $(find . -name '*.tf' -not -path '*/docs/*/example/*' -print0 | xargs -0 -I{} dirname {} | sort -u); do
for WORKSPACE in $(find . -name '*.tf' -not -path '*/.terraform/*' -not -path '*/docs/*/example/*' -print0 | xargs -0 -I{} dirname {} | sort -u); do
bash -e .github/tf.sh "$WORKSPACE" validate
if [[ "true" == "$CI" ]]; then
# Git will refuse to modify untracked nested git repositories (directories with a .git subdirectory) unless a second -f is given.
git clean -ffxd .
fi
done
17 changes: 13 additions & 4 deletions .github/tf.sh
Original file line number Diff line number Diff line change
Expand Up @@ -54,21 +54,30 @@ if [[ "FMT" == "$SAFE_ACTION" ]]; then
fi

set -x
set +e
$IAC_BIN init

TF_INIT_EXIT_CODE=$?
set +x
if [[ "INIT" == "$SAFE_ACTION" ]]; then
set -x
exit 0
exit $TF_INIT_EXIT_CODE
elif [[ "0" != "$TF_INIT_EXIT_CODE" ]]; then
$IAC_BIN providers
set -e
exit $TF_INIT_EXIT_CODE
fi

set -x
set +e
$IAC_BIN validate

TF_VALIDATE_EXIT_CODE=$?
set +x
if [[ "VALIDATE" == "$SAFE_ACTION" ]]; then
set -x
exit 0
exit $TF_VALIDATE_EXIT_CODE
elif [[ "0" != "$TF_VALIDATE_EXIT_CODE" ]]; then
set -e
exit $TF_VALIDATE_EXIT_CODE
fi

set +x
Expand Down