27 lines
603 B
Bash
Executable File
27 lines
603 B
Bash
Executable File
#!/bin/bash
|
|
|
|
# Safe mode(when error,kill script)
|
|
set -euo pipefail
|
|
|
|
# 変数の設定({HOME}/hash.txt からハッシュ値を取得)
|
|
TF_DIR=${TF_DIR:-terraform}
|
|
ENV=${ENV:-dev}
|
|
|
|
cd "$TF_DIR"
|
|
|
|
# --- デプロイ条件 ---
|
|
if [[ "${BRANCH_NAME:-}" =~ ^.*deploy$ ]]; then
|
|
echo "Start terraform apply (ENV=${ENV}, DIR=${TF_DIR}) ..."
|
|
else
|
|
echo "Skip terraform apply (branch=${BRANCH_NAME:-})"
|
|
exit 0
|
|
fi
|
|
|
|
# --- plan 結果があるか確認 ---
|
|
if [[ ! -f tfplan ]]; then
|
|
echo "ERROR: tfplan not found in $(pwd). Run plan step first." >&2
|
|
exit 1
|
|
fi
|
|
|
|
terraform apply -auto-approve tfplan
|