-
Notifications
You must be signed in to change notification settings - Fork 2.2k
115 lines (115 loc) · 4.48 KB
/
infrastructure-tests.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
106
107
108
109
110
111
112
113
114
115
# Copyright (c) HashiCorp, Inc.
# SPDX-License-Identifier: MPL-2.0
name: hashicorp/hashicat-azure/infrastructure-tests
on:
workflow_dispatch:
push:
branches:
- 'master'
env:
# See IL-574 for the source of these
ARM_CLIENT_ID: ${{ vars.ARM_CLIENT_ID }}
ARM_CLIENT_SECRET: ${{ secrets.ARM_CLIENT_SECRET }}
ARM_SUBSCRIPTION_ID: ${{ vars.ARM_SUBSCRIPTION_ID }}
ARM_TENANT_ID: ${{ vars.ARM_TENANT_ID }}
TF_VAR_prefix: gha-infrastructure-tests-${{ github.run_id }}-${{ github.run_number }}
permissions: {}
jobs:
terraform-init:
runs-on: ubuntu-latest
container:
image: docker.mirror.hashicorp.services/hashicorp/terraform:light
permissions:
contents: read
steps:
- uses: actions/checkout@3df4ab11eba7bda6032a0b82a6bb43b11571feac # v4.0.0
- name: Terraform Init
run: terraform init
- uses: actions/upload-artifact@0b7f8abb1508181956e8e162db84b466c27e18ce # v3.1.2
with:
name: "tf-code"
path: ${{ github.workspace }}
terraform-validate:
runs-on: ubuntu-latest
container:
image: docker.mirror.hashicorp.services/hashicorp/terraform:light
needs:
- terraform-init
steps:
- uses: actions/download-artifact@9bc31d5ccc31df68ecc42ccf4149144866c47d8a # v3.0.2
with:
name: "tf-code"
path: ${{ github.workspace }}
# Either upload or download-artifact does not preserve the exec bit on
# binaries, so fix that here
- name: fix-perms
run: |-
# e.g. .terraform/providers/registry.terraform.io/hashicorp/null/3.2.1/linux_amd64/terraform-provider-null_v3.2.1_x5
chmod +x .terraform/providers/*/*/*/*/*/terraform-provider-*
- name: Terraform Validate
run: terraform validate
terraform-plan:
runs-on: ubuntu-latest
container:
image: docker.mirror.hashicorp.services/hashicorp/terraform:light
needs:
- terraform-validate
steps:
- uses: actions/download-artifact@9bc31d5ccc31df68ecc42ccf4149144866c47d8a # v3.0.2
with:
name: "tf-code"
path: ${{ github.workspace }}
# Either upload or download-artifact does not preserve the exec bit on
# binaries, so fix that here
- name: fix-perms
run: |-
# e.g. .terraform/providers/registry.terraform.io/hashicorp/null/3.2.1/linux_amd64/terraform-provider-null_v3.2.1_x5
chmod +x .terraform/providers/*/*/*/*/*/terraform-provider-*
- name: Terraform Plan
run: terraform plan -out=gha-infrastructure-tests-${{ github.run_id }}-${{ github.run_number }}.plan
- uses: actions/upload-artifact@0b7f8abb1508181956e8e162db84b466c27e18ce # v3.1.2
with:
name: "tf-code"
path: ${{ github.workspace }}
terraform-apply:
runs-on: ubuntu-latest
container:
image: docker.mirror.hashicorp.services/hashicorp/terraform:light
needs:
- terraform-plan
steps:
- uses: actions/download-artifact@9bc31d5ccc31df68ecc42ccf4149144866c47d8a # v3.0.2
with:
name: "tf-code"
path: ${{ github.workspace }}
# Either upload or download-artifact does not preserve the exec bit on
# binaries, so fix that here
- name: fix-perms
run: |-
# e.g. .terraform/providers/registry.terraform.io/hashicorp/null/3.2.1/linux_amd64/terraform-provider-null_v3.2.1_x5
chmod +x .terraform/providers/*/*/*/*/*/terraform-provider-*
- name: Terraform Apply
run: terraform apply -auto-approve gha-infrastructure-tests-${{ github.run_id }}-${{ github.run_number }}.plan
- uses: actions/upload-artifact@0b7f8abb1508181956e8e162db84b466c27e18ce # v3.1.2
with:
name: "tf-code"
path: ${{ github.workspace }}
terraform-destroy:
runs-on: ubuntu-latest
container:
image: docker.mirror.hashicorp.services/hashicorp/terraform:light
needs:
- terraform-apply
steps:
- uses: actions/download-artifact@9bc31d5ccc31df68ecc42ccf4149144866c47d8a # v3.0.2
with:
name: "tf-code"
path: ${{ github.workspace }}
# Either upload or download-artifact does not preserve the exec bit on
# binaries, so fix that here
- name: fix-perms
run: |-
# e.g. .terraform/providers/registry.terraform.io/hashicorp/null/3.2.1/linux_amd64/terraform-provider-null_v3.2.1_x5
chmod +x .terraform/providers/*/*/*/*/*/terraform-provider-*
- name: Terraform Destroy
run: terraform destroy -auto-approve