-
Notifications
You must be signed in to change notification settings - Fork 3
105 lines (86 loc) · 2.5 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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
name: Terraform Deployments
on:
pull_request:
push:
branches:
- main
jobs:
lint:
runs-on: ubuntu-latest
defaults:
run:
working-directory: ./terraform
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Set up Terraform
uses: hashicorp/setup-terraform@v3
with:
terraform_version: 1.9.0
- name: Lint Terraform
run: terraform fmt -check
# - name: Lint VCL
# uses: ain/falco-github-action@v1
# with:
# subcommand: lint
# options: "-vv -I ./modules/fastly/vcl/"
# target: ./modules/fastly/vcl/main.vcl
deploy-to-test:
needs: lint
concurrency:
group: ${{ github.workflow }}-test
cancel-in-progress: false
runs-on: ubuntu-latest
env:
FASTLY_API_KEY: ${{ secrets.TERRAFORM_FASTLY_API_KEY }}
TF_WORKSPACE: "test"
TF_LOG: "warn"
defaults:
run:
working-directory: ./terraform
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Set up Terraform
uses: hashicorp/setup-terraform@v3
with:
terraform_version: 1.9.0
cli_config_credentials_token: ${{ secrets.TERRAFORM_API_TOKEN }}
- name: Set-up test workspace
run: |
terraform init
- name: Apply test configuration
run: terraform apply -auto-approve -var-file=environments/test.tfvars
- name: Run tests against test
run: |
echo "Imagine these are real tests"
deploy-to-prod:
if: github.ref == 'refs/heads/main' && github.event_name != 'pull_request'
concurrency:
group: ${{ github.workflow }}-prod
cancel-in-progress: false
runs-on: ubuntu-latest
needs: deploy-to-test
env:
FASTLY_API_KEY: ${{ secrets.TERRAFORM_FASTLY_API_KEY }}
TF_WORKSPACE: "prod"
TF_LOG: "warn"
defaults:
run:
working-directory: ./terraform
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Set up Terraform
uses: hashicorp/setup-terraform@v3
with:
terraform_version: 1.9.0
cli_config_credentials_token: ${{ secrets.TERRAFORM_API_TOKEN }}
- name: Set-up prod workspace
run: |
terraform init
- name: Apply prod configuration
run: terraform apply -auto-approve -var-file=environments/prod.tfvars
- name: Run tests against prod
run: |
echo "Imagine these are real tests"