Skip to content

Commit 05365d9

Browse files
authored
Merge pull request #23 from BerryBytes/feat/precommit-config
Feat/precommit config
2 parents 129aae8 + 1485e9d commit 05365d9

4 files changed

Lines changed: 374 additions & 152 deletions

File tree

.github/workflows/releaser.yaml

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -187,13 +187,3 @@ jobs:
187187
--reviewer enzokamal || echo "PR creation failed, possibly no changes or reviewer issue"
188188
env:
189189
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
190-
191-
# - name: Run GoReleaser
192-
# if: steps.check_commits.outputs.skip != 'true' && steps.commit_changelog.outputs.skip_pr != 'true'
193-
# uses: goreleaser/goreleaser-action@v6
194-
# with:
195-
# distribution: goreleaser
196-
# version: v2.9.0
197-
# args: release --clean --release-notes=RELEASE_NOTES.md
198-
# env:
199-
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
name: Sync Pre-commit Config
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
paths:
8+
- ".pre-commit-config.yaml"
9+
- "precommitFile/**"
10+
workflow_dispatch:
11+
12+
permissions:
13+
contents: write
14+
15+
jobs:
16+
sync-config:
17+
runs-on: ubuntu-latest
18+
19+
steps:
20+
- name: Checkout repository
21+
uses: actions/checkout@v4
22+
with:
23+
fetch-depth: 0
24+
25+
- name: Ensure precommitFile directory exists
26+
run: mkdir -p precommitFile
27+
28+
- name: Copy .pre-commit-config.yaml to precommitFile directory
29+
run: cp .pre-commit-config.yaml precommitFile/.pre-commit-config.yaml
30+
31+
- name: Check for changes
32+
id: git_status
33+
run: |
34+
if git diff --quiet; then
35+
echo "changed=false" >> $GITHUB_OUTPUT
36+
else
37+
echo "changed=true" >> $GITHUB_OUTPUT
38+
fi
39+
40+
- name: Commit and push changes
41+
if: steps.git_status.outputs.changed == 'true'
42+
run: |
43+
git config user.name "GitHub Actions"
44+
git config user.email "actions@github.com"
45+
46+
git add precommitFile/.pre-commit-config.yaml
47+
git commit -m "Sync .pre-commit-config.yaml to precommitFile directory"
48+
git push

global/commit-msg.sh

Lines changed: 0 additions & 82 deletions
Original file line numberDiff line numberDiff line change
@@ -1,85 +1,3 @@
1-
# #!/usr/bin/env bash
2-
# set -euo pipefail
3-
4-
# # Create commitlint config if it doesn't exist
5-
# if [ ! -f "$(git rev-parse --show-toplevel)/commitlint.config.js" ]; then
6-
# cat << 'CONFIG_EOF' > "$(git rev-parse --show-toplevel)/commitlint.config.js"
7-
# module.exports = {
8-
# extends: ['@commitlint/config-conventional'],
9-
# rules: {
10-
# 'type-enum': [2, 'always', [
11-
# 'feat', // A new feature
12-
# 'fix', // A bug fix
13-
# 'docs', // Documentation only changes
14-
# 'style', // Changes that do not affect code meaning
15-
# 'refactor', // A code change that neither fixes a bug nor adds a feature
16-
# 'perf', // A code change that improves performance
17-
# 'test', // Adding missing tests or correcting existing tests
18-
# 'build', // Build system or external dependencies
19-
# 'ci', // CI configuration changes
20-
# 'chore', // Other changes that don't modify src or test files
21-
# 'revert', // Reverts a previous commit
22-
# ]],
23-
# 'type-case': [2, 'always', 'lowerCase'],
24-
# 'type-empty': [2, 'never'],
25-
# 'scope-case': [2, 'always', 'lowerCase'],
26-
# 'subject-empty': [2, 'never'],
27-
# 'subject-full-stop': [2, 'never', '.'],
28-
# 'header-max-length': [2, 'always', 72],
29-
# },
30-
# };
31-
# CONFIG_EOF
32-
# echo "✅ Created commitlint.config.js in repository root"
33-
# fi
34-
35-
# # Ensure commitlint is available
36-
# if ! command -v commitlint >/dev/null 2>&1; then
37-
# echo "⚙️ Installing commitlint globally..."
38-
# npm install -g @commitlint/cli @commitlint/config-conventional >/dev/null 2>&1
39-
# fi
40-
41-
# # Read commit message
42-
# commit_msg_file="$1"
43-
# commit_msg=$(cat "$commit_msg_file")
44-
45-
# # Run commitlint and capture output (important!)
46-
# lint_output=$(echo "$commit_msg" | commitlint 2>&1) || lint_status=$?
47-
48-
# if [ "${lint_status:-0}" -ne 0 ]; then
49-
# RED='\033[0;31m'
50-
# YELLOW='\033[1;33m'
51-
# NC='\033[0m'
52-
53-
# echo -e "${RED}\n❌ Commit message format error detected.${NC}"
54-
# echo -e "${YELLOW}\nCommit message must follow the Conventional Commit format:\n${NC}"
55-
# echo -e "${YELLOW} type(scope): subject${NC}"
56-
# echo -e "\n${YELLOW}Types:${NC}"
57-
# echo " feat : A new feature"
58-
# echo " fix : A bug fix"
59-
# echo " docs : Documentation only changes"
60-
# echo " style : Changes that do not affect code meaning"
61-
# echo " refactor : Code change that neither fixes a bug nor adds a feature"
62-
# echo " perf : Code change that improves performance"
63-
# echo " test : Adding or correcting tests"
64-
# echo " build : Changes to the build system or external dependencies"
65-
# echo " ci : CI configuration or scripts"
66-
# echo " chore : Other changes that don't modify src or test files"
67-
# echo " revert : Reverts a previous commit"
68-
# echo -e "\n${YELLOW}Examples:${NC}"
69-
# echo " feat(auth): add password reset functionality"
70-
# echo " fix(api): handle null server response"
71-
# echo " docs(readme): update installation instructions"
72-
73-
# echo -e "\n${RED}Commitlint output:${NC}"
74-
# echo "$lint_output"
75-
76-
# echo -e "\n${RED}❗ Please fix your commit message and try again.${NC}"
77-
# exit 1
78-
# else
79-
# echo -e "\033[0;32m✅ Commit message passed Conventional Commit check.\033[0m"
80-
# fi
81-
82-
831
#!/usr/bin/env bash
842
set -euo pipefail
853

0 commit comments

Comments
 (0)