-
Notifications
You must be signed in to change notification settings - Fork 16
76 lines (61 loc) · 2 KB
/
terraform.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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
name: 'Terraform'
on:
push:
branches:
- master
pull_request:
paths:
- 'config/terraform/aws/*'
defaults:
run:
shell: bash
working-directory: config/terraform/aws
env:
AWS_ACCESS_KEY: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
AWS_REGION: ca-central-1
TF_VAR_ecs_task_portal_env_rails_master_key: ${{ secrets.TF_VAR_ecs_task_portal_env_rails_master_key }}
TF_VAR_rds_portal_db_password: ${{ secrets.TF_VAR_rds_portal_db_password }}
jobs:
terraform-plan:
if: github.ref != 'refs/heads/master' && github.repository_owner == 'CovidShield'
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Setup Terraform
uses: hashicorp/setup-terraform@da17847d115ff1e5987848a1030cfc415b0a3a5c
- name: Terraform Init
run: terraform init
- name: Terraform Format
run: terraform fmt -check
- name: Terraform Plan
run: terraform plan
terraform-apply:
if: github.ref == 'refs/heads/master' && github.event_name == 'push' && github.repository_owner == 'CovidShield'
runs-on: ubuntu-latest
steps:
- name: Wait for container to be built and pushed
uses: fountainhead/[email protected]
id: wait-for-build
with:
token: ${{ secrets.GITHUB_TOKEN }}
checkName: build-n-push
ref: ${{ github.sha }}
- name: Checkout
if: steps.wait-for-build.outputs.conclusion == 'success'
uses: actions/checkout@v2
- name: Setup Terraform
uses: hashicorp/setup-terraform@da17847d115ff1e5987848a1030cfc415b0a3a5c
- name: Terraform Init
run: terraform init
- name: Terraform Format
run: terraform fmt -check
- name: Terraform Plan
env:
TF_VAR_github_sha: ${{ github.sha }}
run: terraform plan -out terraform.tfplan
- name: Terraform Apply
env:
TF_VAR_github_sha: ${{ github.sha }}
run: terraform apply -auto-approve terraform.tfplan