35 lines
732 B
Bash
35 lines
732 B
Bash
#!/bin/bash
|
|
set -euo pipefail
|
|
|
|
echo "stages:"
|
|
echo " - validate"
|
|
echo " - deploy"
|
|
|
|
for dir in templates/*; do
|
|
[ -d "$dir" ] || continue
|
|
name=$(basename "$dir")
|
|
|
|
cat <<EOF
|
|
|
|
validate_${name}:
|
|
stage: validate
|
|
image: registry.bobert.me/anthorob/coder-images:terraform-shell
|
|
script:
|
|
- terraform -chdir=$dir init -backend=false
|
|
- terraform -chdir=$dir validate
|
|
|
|
deploy_${name}:
|
|
stage: deploy
|
|
image: registry.bobert.me/anthorob/coder-images:coder-cli
|
|
script:
|
|
- cd $dir
|
|
- coder templates push ${name} --tag "${CI_COMMIT_SHORT_SHA}" --description "Auto-deployed from ${CI_PROJECT_PATH} on commit ${CI_COMMIT_SHORT_SHA}" --latest --yes
|
|
only:
|
|
refs:
|
|
- main
|
|
changes:
|
|
- $dir/**
|
|
EOF
|
|
|
|
done
|