diff options
Diffstat (limited to 'scripts/ci/provision.sh')
-rwxr-xr-x | scripts/ci/provision.sh | 22 |
1 files changed, 18 insertions, 4 deletions
diff --git a/scripts/ci/provision.sh b/scripts/ci/provision.sh index a89ffc5..4ae29e5 100755 --- a/scripts/ci/provision.sh +++ b/scripts/ci/provision.sh @@ -13,16 +13,30 @@ VPS_COMMIT_SHA="$(git rev-parse HEAD)" envsubst < ./scripts/box/run-backup-templ ssh "$TLD" /home/vps/run-backup.sh echo "Done." -echo "Running 'terraform apply'..." +echo "Running 'terraform plan' and storing the planfile..." +# Terraform plan terraform --version terraform init -terraform apply +mkdir -p "../vps-state/secrets/plan-files/" +PLAN_FILE="../vps-state/secrets/plan-files/$(date -Iseconds)-$(git rev-parse HEAD).tfplan" +terraform plan -input=false -out="$PLAN_FILE" + +# Store on git repo +pushd ../vps-state/ +git add "secrets/plan-files/$PLAN_FILE" +git commit -m "CI: add .tfplan plan file for CI run $(git rev-parse HEAD)" +git push origin master +popd +echo "Done." + +echo "Running 'terraform apply'..." +terraform apply -input=false -auto-approve "$PLAN_FILE" echo "Done." -echo "Storing .tfstate file" +echo "Storing .tfstate file..." pushd ../vps-state/ git add secrets/terraform.tfstate secrets/terraform.tfstate.backup -git commit -m "CI: update Terraform .tfstate files" +git commit -m "CI: update Terraform .tfstate files for CI run $(git rev-parse HEAD)" git push origin master popd echo "Done." |