-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path.pre-commit-config.yaml
More file actions
74 lines (63 loc) · 2.19 KB
/
Copy path.pre-commit-config.yaml
File metadata and controls
74 lines (63 loc) · 2.19 KB
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
repos:
# Terraform hooks
- repo: https://github.com/antonbabenko/pre-commit-terraform
rev: v1.104.0
hooks:
# Format terraform files
- id: terraform_fmt
name: Terraform fmt
description: Rewrites all Terraform files to canonical format
# Validate terraform files
- id: terraform_validate
name: Terraform validate
description: Validates all Terraform files
args:
- --hook-config=--retry-once-with-cleanup=true
- --tf-init-args=-backend=false
# Run tflint
- id: terraform_tflint
name: Terraform tflint
description: Runs tflint on Terraform files
exclude: (.*/)?(tests|_template)/.*
args:
- --args=--config=__GIT_WORKING_DIR__/terraform/.tflint.hcl
# Generate terraform docs (optional)
- id: terraform_docs
name: Terraform docs
description: Inserts terraform-docs output into README.md
exclude: (.*/)?(tests|_template)/.*
args:
- --hook-config=--path-to-file=README.md
- --hook-config=--add-to-existing-file=true
- --hook-config=--create-file-if-not-exist=true
# Run trivy
- id: terraform_trivy
name: Terraform trivy
description: Runs trivy security scanner
args:
- --args=--config=__GIT_WORKING_DIR__/terraform/.trivy.yaml
# General file checks
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.5.0
hooks:
# Prevent committing large files
- id: check-added-large-files
args: ['--maxkb=1000']
# Check for merge conflicts
- id: check-merge-conflict
# Check YAML syntax
- id: check-yaml
args: ['--unsafe'] # Allow custom tags in GitHub Actions
# Trim trailing whitespace
- id: trailing-whitespace
args: ['--markdown-linebreak-ext=md']
# Ensure files end with newline
- id: end-of-file-fixer
# Check for secrets
- id: detect-private-key
# Prevent commits to main branch
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.5.0
hooks:
- id: no-commit-to-branch
args: ['--branch', 'main', '--branch', 'master']