-
Notifications
You must be signed in to change notification settings - Fork 1
66 lines (57 loc) · 1.76 KB
/
reusable-validate.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
58
59
60
61
62
63
64
65
66
name: reusable/validate
on:
workflow_call:
secrets:
appId:
description: 'GitHub Application ID'
required: false
appPrivateKey:
description: 'GitHub Application private key'
required: false
inputs:
terraformVersion:
description: 'Defines terraform version to use'
required: true
type: string
moduleRootDirectory:
description: 'Defines root module directory'
required: true
type: string
jobs:
validate:
runs-on: ubuntu-latest
defaults:
run:
working-directory: ${{ inputs.moduleRootDirectory }}
steps:
- name: Terraform-SetupWithCloud
uses: hashicorp/[email protected]
with:
terraform_version: ${{ inputs.terraformVersion }}
- name: Checkout
uses: actions/checkout@v4
- name: Generate token
env:
APP_ID: ${{ secrets.appId }}
PRIVATE_KEY: ${{ secrets.appPrivateKey }}
if: ${{ env.APP_ID != null && env.PRIVATE_KEY != null }}
id: generate_token
uses: tibdex/github-app-token@v2
with:
app_id: ${{ secrets.appId }}
private_key: ${{ secrets.appPrivateKey }}
- name: authenticate to git with app token
env:
APP_ID: ${{ secrets.appId }}
PRIVATE_KEY: ${{ secrets.appPrivateKey }}
if: ${{ env.APP_ID != null && env.PRIVATE_KEY != null }}
run: |
echo ${{ steps.generate_token.outputs.token }} | gh auth login --with-token
gh auth setup-git
- name: Format
run: |
terraform fmt -write=false -diff -check
- name: Validate
run: |
terraform init --backend=false
terraform validate