feat: only run apply when plan detects changes
ci/woodpecker/pr/pre-commit Pipeline failed
ci/woodpecker/pr/plan Pipeline was successful

This commit is contained in:
2026-06-11 23:21:51 +10:00
parent 148a9f4962
commit 1a5921d9b0
2 changed files with 14 additions and 2 deletions
+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