File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ # #!/bin/bash
2+
3+ # # Extract the YAML config from setup_pre_commit_config function in global/pre-commit.sh
4+ # # and save it to global/precommitFile/.pre-commit-config.yaml
5+
6+ # mkdir -p global/precommitFile
7+
8+ # sed -n '/cat > "\$file" <<'\''EOF'\''/,/EOF/p' global/pre-commit.sh | sed '1d;$d' > global/precommitFile/.pre-commit-config.yaml
9+
10+ # echo "Config extracted to global/precommitFile/.pre-commit-config.yaml"
11+
12+ #! /bin/bash
13+
14+ # List of directories in root that may contain pre-commit.sh
15+ LANG_DIRS=(" global" " golang" " python" " terraform" " typescript" )
16+
17+ echo " 🔍 Searching for pre-commit.sh in project folders..."
18+
19+ for dir in " ${LANG_DIRS[@]} " ; do
20+ script_path=" $dir /pre-commit.sh"
21+
22+ if [[ -f " $script_path " ]]; then
23+ echo " ➡️ Found: $script_path "
24+
25+ # Create destination folder
26+ dest_dir=" $dir /precommitFile"
27+ mkdir -p " $dest_dir "
28+
29+ # Output file
30+ dest_file=" $dest_dir /.pre-commit-config.yaml"
31+
32+ # Extract YAML using sed
33+ sed -n " /cat > \"\\\$ file\" <<'EOF'/,/EOF/p" " $script_path " \
34+ | sed ' 1d;$d' > " $dest_file "
35+
36+ echo " ✓ Extracted config → $dest_file "
37+ else
38+ echo " ⚠️ No pre-commit.sh found in $dir — skipping."
39+ fi
40+ done
41+
42+ echo " ✅ Extraction complete!"
Original file line number Diff line number Diff line change 2626 persist-credentials : true
2727
2828 - name : Extract config from script
29- run : bash global/extract_config.sh
30-
31- # - name: Validate YAML syntax
32- # run: |
33- # if command -v yamllint >/dev/null 2>&1; then
34- # yamllint global/precommitFile/.pre-commit-config.yaml
35- # else
36- # python3 -c "import yaml; yaml.safe_load(open('global/precommitFile/.pre-commit-config.yaml'))"
37- # fi
38-
39- # - name: Copy updated pre-commit config to root
40- # run: |
41- # cp global/precommitFile/.pre-commit-config.yaml .pre-commit-config.yaml
29+ run : |
30+ chmod +x .github/scripts/extract_config.sh
31+ .github/scripts/extract_config.sh
4232
4333 - name : Check if changes exist
4434 id : changes
Original file line number Diff line number Diff line change 1- #! /bin/bash
1+ # # !/bin/bash
22
3- # Extract the YAML config from setup_pre_commit_config function in global/pre-commit.sh
4- # and save it to global/precommitFile/.pre-commit-config.yaml
3+ # # Extract the YAML config from setup_pre_commit_config function in global/pre-commit.sh
4+ # # and save it to global/precommitFile/.pre-commit-config.yaml
55
6- mkdir -p global/precommitFile
6+ # mkdir -p global/precommitFile
77
8- sed -n ' /cat > "\$file" <<' \' ' EOF' \' ' /,/EOF/p' global/pre-commit.sh | sed ' 1d;$d' > global/precommitFile/.pre-commit-config.yaml
8+ # sed -n '/cat > "\$file" <<'\''EOF'\''/,/EOF/p' global/pre-commit.sh | sed '1d;$d' > global/precommitFile/.pre-commit-config.yaml
99
10- echo " Config extracted to global/precommitFile/.pre-commit-config.yaml"
10+ # echo "Config extracted to global/precommitFile/.pre-commit-config.yaml"
Original file line number Diff line number Diff line change @@ -68,7 +68,7 @@ setup_pre_commit_config() {
6868 if [[ ! -f " $file " ]]; then
6969 cat > " $file " << 'EOF '
7070repos:
71- # ✅ Precommit hooks
71+ ############ ✅ Precommit hooks #############
7272 - repo: https://github.com/pre-commit/pre-commit-hooks
7373 rev: v4.4.0
7474 hooks:
8181 - id: destroyed-symlinks
8282 - id: pretty-format-json
8383
84- # ✅ golang fmt and go tidey
84+ ########## ✅ golang fmt and go tidey #########
8585 - repo: https://github.com/TekWizely/pre-commit-golang
8686 rev: v1.0.0-rc.1
8787 hooks:
Original file line number Diff line number Diff line change 11repos :
2- # ✅ Precommit hooks
2+ # ########### ✅ Precommit hooks #############
33 - repo : https://github.com/pre-commit/pre-commit-hooks
44 rev : v4.4.0
55 hooks :
1212 - id : destroyed-symlinks
1313 - id : pretty-format-json
1414
15- # ✅ golang fmt and go tidey
15+ # ######### ✅ golang fmt and go tidey #########
1616 - repo : https://github.com/TekWizely/pre-commit-golang
1717 rev : v1.0.0-rc.1
1818 hooks :
Original file line number Diff line number Diff line change @@ -64,6 +64,7 @@ setup_pre_commit_config() {
6464
6565 cat > " $file " << 'EOF '
6666repos:
67+ ############ ✅ Precommit hooks #############
6768 - repo: https://github.com/pre-commit/pre-commit-hooks
6869 rev: v4.4.0
6970 hooks:
Original file line number Diff line number Diff line change 1+ repos :
2+ # ########### ✅ Precommit hooks #############
3+ - repo : https://github.com/pre-commit/pre-commit-hooks
4+ rev : v4.4.0
5+ hooks :
6+ - id : check-yaml
7+ args : ["--allow-multiple-documents"]
8+ - id : end-of-file-fixer
9+ - id : trailing-whitespace
10+ - id : check-added-large-files
11+ - id : check-vcs-permalinks
12+ - id : check-symlinks
13+ - id : destroyed-symlinks
14+
15+ - repo : https://github.com/TekWizely/pre-commit-golang
16+ rev : v1.0.0-rc.1
17+ hooks :
18+ - id : go-fmt
19+ args : [-w]
20+ - id : go-mod-tidy # Ensure go.mod & go.sum are tidy
21+
22+
23+ - repo : https://github.com/codespell-project/codespell
24+ rev : v2.2.5
25+ hooks :
26+ - id : codespell
27+ files : ^.*\.(py|c|h|md|rst|yml|go|sh|sql|tf|yaml)$
28+ exclude : ^.*(_test\.go|\.min\.js|\.map)$
29+ args : ["--ignore-words-list", "hist,nd"]
30+
31+ - repo : https://github.com/zricethezav/gitleaks
32+ rev : v8.18.0
33+ hooks :
34+ - id : gitleaks
35+ args : ["detect", "--verbose"]
Original file line number Diff line number Diff line change @@ -60,7 +60,7 @@ setup_pre_commit_config() {
6060
6161 cat > " $config " << 'EOF '
6262repos:
63- # ✅ Generic pre-commit hygiene
63+ ############ ✅ Precommit hooks #############
6464 - repo: https://github.com/pre-commit/pre-commit-hooks
6565 rev: v6.0.0
6666 hooks:
Original file line number Diff line number Diff line change @@ -44,6 +44,7 @@ setup_pre_commit_config() {
4444 if [ ! -f " $pre_commit_config " ]; then
4545 cat > " $pre_commit_config " << EOF
4646repos:
47+ ############ ✅ Terraform Docs #############
4748 - repo: https://github.com/terraform-docs/terraform-docs
4849 rev: "v0.16.0"
4950 hooks:
You can’t perform that action at this time.
0 commit comments