デプロイソースを整備する
This commit is contained in:
parent
2edea8d13c
commit
3c1c8159d4
9
.github/workflows/deploy_to_gcp.yml
vendored
9
.github/workflows/deploy_to_gcp.yml
vendored
@ -56,4 +56,13 @@ jobs:
|
||||
export GOOGLE_APPLICATION_CREDENTIALS="$HOME/sa.json"
|
||||
./scripts/deploy/plan_terraform.sh
|
||||
|
||||
- name: Exec Terraform apply shell
|
||||
run: |
|
||||
export GOOGLE_APPLICATION_CREDENTIALS="$HOME/sa.json"
|
||||
./scripts/deploy/apply_terraform.sh
|
||||
|
||||
- name: Clean up Gcloud auth file
|
||||
run: |
|
||||
rm -f $HOME/sa.json
|
||||
echo "Cleaned up Gcloud auth file."
|
||||
|
||||
|
||||
26
scripts/deploy/applay_terraform.sh
Executable file
26
scripts/deploy/applay_terraform.sh
Executable file
@ -0,0 +1,26 @@
|
||||
#!/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
|
||||
Loading…
x
Reference in New Issue
Block a user