-
Notifications
You must be signed in to change notification settings - Fork 11
88 lines (86 loc) · 2.68 KB
/
terraform_plan.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
name: terraform plan
on:
pull_request:
branches:
- main
paths:
- terraform/**
pull_request_target:
branches:
- main
paths:
- terraform/**
jobs:
validate:
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
LOGIN: ${{ github.actor }}
PR_REPO_FULL_NAME: ${{ github.event.pull_request.head.repo.full_name }}
runs-on: ubuntu-latest
defaults:
run:
working-directory: ./terraform
outputs:
valid_workflow: ${{ steps.validate_workflow.outputs.valid_workflow }}
steps:
- uses: actions/checkout@v2
- name: Install and configure Poetry
uses: snok/install-poetry@2bf112a0f6979928eb6b011f39700db589c5961e #v1
with:
virtualenvs-create: true
virtualenvs-in-project: true
version: 1.1.13
- name: Install library
run: |
cd scripts
poetry install
- name: Run tests
run: |
cd scripts
poetry run pytest --cov validate .
- name: validate_workflow
id: validate_workflow
run: |
cd scripts
output=$(poetry run python validate.py)
echo "valid_workflow=$output" >> "$GITHUB_OUTPUT"
plan:
env:
AWS_ACCESS_KEY_ID: ${{ secrets.TERRAFORM_AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.TERRAFORM_AWS_SECRET_ACCESS_KEY }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
TF_VAR_tvm_bot_webhook_secret: ${{ secrets.TVM_BOT_WEBHOOK_SECRET }}
TF_VAR_tvm_bot_github_token: ${{ secrets.TVM_BOT_GITHUB_TOKEN }}
TF_VAR_tvm_bot_repo: tvm
TF_VAR_tvm_bot_owner: apache
runs-on: ubuntu-latest
defaults:
run:
working-directory: ./terraform
needs: validate
if: needs.validate.outputs.valid_workflow == 'True'
# These steps run if either the PR is within the same repo or if the PR is
# on a fork and the committer has deployer access
steps:
- uses: actions/checkout@v2
with:
ref: ${{ github.event.pull_request.head.sha }}
- name: Terraform fmt
id: fmt
uses: dflook/terraform-fmt@f0d4aaacfe91d9319a40cbb2bfeb5bd0ee2f2739 #v1.25.1
continue-on-error: true
with:
path: ./terraform
- name: Terraform Validate
id: validate
uses: dflook/terraform-validate@85bc5b5cab93240dc66bf7b9e744570f12ace9d6 #v1.25.1
with:
path: ./terraform
- name: Terraform Plan
uses: dflook/terraform-plan@7196a67f47a16ef4f7e12ff0b55205e5eb2cee55 #v1.25.1
id: plan
with:
var_file: |
terraform/vars/tvm-ci-prod.auto.tfvars
path: ./terraform
workspace: tvm-ci-prod