-
Notifications
You must be signed in to change notification settings - Fork 0
57 lines (54 loc) · 1.61 KB
/
actions-demo.yaml
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
name: Terraform Github Actions
run-name: ${{ github.actor }} is testing GitHub Actions 🚀
on: [push]
defaults:
run:
working-directory: ./terraform
env:
NSXT_MANAGER_HOST: ${{ secrets.NSXT_MANAGER_HOST }}
NSXT_USERNAME: ${{ secrets.NSXT_USERNAME }}
NSXT_PASSWORD: ${{ secrets.NSXT_PASSWORD }}
S3_ACCESS_KEY: ${{ secrets.S3_ACCESS_KEY }}
S3_SECRET_KEY: ${{ secrets.S3_SECRET_KEY }}
jobs:
Validate:
runs-on: [self-hosted]
container:
image: hashicorp/terraform
steps:
- name: clone repository
uses: actions/checkout@v2
- name: terraform init
id: init
run: terraform init -backend-config="access_key=${S3_ACCESS_KEY}" -backend-config="secret_key=${S3_SECRET_KEY}"
continue-on-error: false
- name: terraform fmt
id: fmt
run: terraform fmt -check -recursive -diff
continue-on-error: false
- name: terraform validate
id: validate
run: terraform validate
continue-on-error: false
Plan:
needs: [Validate]
runs-on: [self-hosted]
container:
image: hashicorp/terraform
steps:
- name: terraform init
id: init
run: terraform init -backend-config="access_key=${S3_ACCESS_KEY}" -backend-config="secret_key=${S3_SECRET_KEY}"
- name: terraform plan
id: plan
run: terraform plan -out=planfile
Apply:
needs: [Validate, Plan]
runs-on: [self-hosted]
if: ${{ github.ref == 'refs/heads/main' }}
container:
image: hashicorp/terraform
steps:
- name: terraform apply
id: apply
run: terraform apply -input=false "planfile"