feat: only run apply when plan detects changes #4

Merged
benvin merged 6 commits from feat/conditional-apply into main 2026-06-11 23:32:02 +10:00
2 changed files with 14 additions and 2 deletions
Showing only changes of commit 1a5921d9b0 - Show all commits
+1 -2
View File
@@ -9,8 +9,7 @@ steps:
VAULT_AUTH_METHOD: kubernetes
commands:
- dnf install vault -y
- make plan
- make apply
- make apply-if-changes
backend_options:
kubernetes:
serviceAccountName: terraform-git
+13
View File
@@ -25,6 +25,19 @@ plan: init
@$(call vault_env) && \
terragrunt run --all --parallelism 4 --non-interactive plan
apply-if-changes: init
@$(call vault_env) && \
terragrunt run --all --parallelism 4 --non-interactive plan -- -detailed-exitcode -out=tfplan; \
EXIT_CODE=$$?; \
if [ $$EXIT_CODE -eq 2 ]; then \
$(call vault_env) && \
terragrunt run --all --parallelism 2 --non-interactive apply -- tfplan; \
elif [ $$EXIT_CODE -eq 0 ]; then \
echo "No changes detected, skipping apply."; \
else \
exit $$EXIT_CODE; \
fi
apply: init
@$(call vault_env) && \
terragrunt run --all --parallelism 2 --non-interactive apply