-
Notifications
You must be signed in to change notification settings - Fork 5
76 lines (65 loc) · 2.09 KB
/
ci.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
name: CI
on:
pull_request:
branches: [main]
types: [opened, reopened, synchronize, edited]
env:
tf_working_dir: "./examples/ci"
aws_account: "977306314792"
aws_gha_role: terraform-fargate-api-dev-gha
jobs:
format:
name: Terraform Format
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Terraform Setup
uses: hashicorp/setup-terraform@v2
with:
terraform_version: '1.3.x'
- name: Terraform Format
working-directory: "./"
run: terraform fmt -check -recursive -diff
plan:
name: Terraform Plan
runs-on: ubuntu-latest
strategy:
matrix:
terraform: [ '1.3.x' ]
fail-fast: false
permissions:
contents: read
actions: read
pull-requests: write
id-token: write
steps:
- uses: actions/checkout@v3
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v2
with:
role-to-assume: "arn:aws:iam::${{ env.aws_account }}:role/${{ env.aws_gha_role }}"
role-session-name: ${{ github.sha }}
aws-region: us-west-2
- name: Terraform Setup
uses: hashicorp/setup-terraform@v2
with:
terraform_version: ${{ matrix.terraform }}
- name: Terraform Init
working-directory: ${{ env.tf_working_dir }}
run: terraform init
- name: Terraform Plan
working-directory: ${{ env.tf_working_dir }}
run: terraform plan.tfplan -input=false -out=plan.tfplan
- name: Comment Terraform Plan
uses: byu-oit/github-action-tf-plan-comment@v1
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
working-directory: ${{ env.tf_working_dir }}
terraform-plan-file: plan.tfplan
- name: Analyze Terraform Plan
uses: byu-oit/github-action-tf-plan-analyzer@v2
with:
divvycloud-username: ${{ secrets.DIVVYCLOUD_USERNAME }}
divvycloud-password: ${{ secrets.DIVVYCLOUD_PASSWORD }}
working-directory: ${{ env.tf_working_dir }}
terraform-plan-file: plan.tfplan