-
Notifications
You must be signed in to change notification settings - Fork 16
48 lines (40 loc) · 1.17 KB
/
terraform-deploy.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
name: Deploy to a terraform target
on:
push:
branches:
- 'main'
- 'targets/*'
paths:
- 'iac/terraform/*'
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
submodules: true
- uses: google-github-actions/setup-gcloud@v1
with:
service_account_key: ${{ secrets.GCP_SA_KEY }}
export_default_credentials: true
- uses: hashicorp/setup-terraform@v2
with:
terraform_version: 1.1.7
terraform_wrapper: false
- name: terraform-deploy
shell: bash
env:
CONTENT_ROOT : ${{ github.workspace }}/iac
ENGINE_ROOT : ${{ github.workspace }}/iac/.engine
run: |
if [[ $GITHUB_REF == refs/heads/main ]]; then
export INFRA_TARGET_NAME=prod
else
export INFRA_TARGET_NAME=${GITHUB_BASE_BRANCH#targets/}
if [[ $INFRA_TARGET_NAME == prod ]]; then
echo "fatal: prod changes must be merged to main branch" >&2
exit 1
fi
fi
"$ENGINE_ROOT"/bin/terraform-deploy