Skip to content

Commit 4f77e6d

Browse files
add pre-commit config
1 parent d1e7a30 commit 4f77e6d

File tree

2 files changed

+54
-0
lines changed

2 files changed

+54
-0
lines changed
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
name: Pre-commit Check
2+
3+
on:
4+
pull_request:
5+
branches: [ main ]
6+
7+
jobs:
8+
pre-commit:
9+
runs-on: ubuntu-latest
10+
steps:
11+
- uses: actions/checkout@v4
12+
13+
- name: Get changed files
14+
uses: tj-actions/changed-files@v41
15+
id: changed-files
16+
17+
- name: Set up Python
18+
uses: actions/setup-python@v4
19+
with:
20+
python-version: '3.x'
21+
22+
- name: Set up Terraform
23+
uses: hashicorp/setup-terraform@v3
24+
with:
25+
terraform_version: latest
26+
27+
- name: Install pre-commit
28+
run: pip install pre-commit
29+
30+
- name: Run pre-commit on changed files
31+
run: |
32+
pre-commit run --files ${{ steps.changed-files.outputs.all_changed_files }} --hook-stage push

.pre-commit-config.yaml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
repos:
2+
- repo: local
3+
hooks:
4+
- id: terraform_clean
5+
name: "Terraform Cleanup"
6+
pass_filenames: false
7+
language: system
8+
entry: bash -c "find . \( -iname ".terraform*" ! -iname ".terraform-docs*" ! -path "*/test/*" \) -print0 | xargs -0 rm -r; true"
9+
- repo: https://github.com/antonbabenko/pre-commit-terraform
10+
rev: v1.88.4
11+
hooks:
12+
- id: terraform_fmt
13+
- repo: https://github.com/pre-commit/pre-commit-hooks
14+
rev: v4.5.0
15+
hooks:
16+
- id: trailing-whitespace
17+
- id: end-of-file-fixer
18+
- id: check-yaml
19+
- id: check-added-large-files
20+
- id: check-merge-conflict
21+
- id: no-commit-to-branch
22+
args: [--branch, main, --pattern, ".*/.*"]

0 commit comments

Comments
 (0)