-
Notifications
You must be signed in to change notification settings - Fork 58
91 lines (71 loc) · 1.81 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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
name: 'Terraform'
on:
push:
branches: [master]
schedule:
- cron: '0 0 * * *'
jobs:
terraform:
name: 'Terraform'
runs-on: ubuntu-latest
environment: production
defaults:
run:
shell: bash
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Setup Terraform
uses: hashicorp/setup-terraform@v1
with:
terraform_version: 0.14.7
terraform_wrapper: false
- name: Setup Go
uses: actions/setup-go@v2
with:
go-version: 1.16
- name: Terraform Init
run: terraform init
- name: Terraform Format
run: terraform fmt -check
- name: Setup Terraform Vars
run: |
cat > .auto.tfvars <<EOF
github_token = "${{ secrets.ORG_ADMIN_GITHUB_TOKEN }}"
mailgun_api_key = "${{ secrets.MAILGUN_API_KEY }}"
EOF
- name: Setup Terraform State
uses: actions/cache@v2
with:
path: terraform.tfstate
key: terraform-state-${{ github.sha }}
restore-keys: terraform-state-
- name: Terraform Import
run: go run ./cmd/import
env:
GITHUB_TOKEN: ${{ secrets.ORG_ADMIN_GITHUB_TOKEN }}
MAILGUN_API_KEY: ${{ secrets.MAILGUN_API_KEY }}
- name: Terraform Plan
run: terraform plan -out=tfplan
- name: Terraform Apply
run: terraform apply tfplan
test:
needs: terraform
name: 'Run Tests'
runs-on: ubuntu-latest
environment: production
defaults:
run:
shell: bash
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Setup Go
uses: actions/setup-go@v2
with:
go-version: 1.16
- name: Run Tests
run: go test
env:
GITHUB_TOKEN: ${{ secrets.ORG_ADMIN_GITHUB_TOKEN }}
MAILGUN_API_KEY: ${{ secrets.MAILGUN_API_KEY }}