-
Notifications
You must be signed in to change notification settings - Fork 0
98 lines (76 loc) · 2.6 KB
/
Copy pathcommit-flow.yml
File metadata and controls
98 lines (76 loc) · 2.6 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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
---
name: Commit Check
on:
workflow_dispatch:
jobs:
commit-check:
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Checkout
uses: actions/checkout@v6
with:
fetch-depth: 30
- name: Setup Git
run: |
git config --global user.name "github-actions[bot]"
git config --global user.email "github-actions[bot]@users.noreply.github.com"
- name: Check commits
id: flow
run: |
echo "[INFO] Analyzing commit flow..."
total=0; aligned=0
pattern="^(feat|fix|docs|style|refactor|test|chore|perf|ci|build)\("
while read -r subject; do
total=$((total + 1))
if [[ "$subject" =~ $pattern ]]; then
aligned=$((aligned + 1))
fi
done < <(git log --oneline -20 --pretty=format:"%s")
score=$(( total > 0 ? (aligned * 100) / total : 0 ))
echo "score=$score" >> $GITHUB_OUTPUT
echo "aligned=$aligned" >> $GITHUB_OUTPUT
echo "total=$total" >> $GITHUB_OUTPUT
echo "[INFO] Flow score: $score% ($aligned/$total aligned)"
- name: Report
run: |
score=${{ steps.flow.outputs.score }}
aligned=${{ steps.flow.outputs.aligned }}
total=${{ steps.flow.outputs.total }}
if [ $score -ge 80 ]; then
status="HARMONIZED"
elif [ $score -ge 60 ]; then
status="ALIGNED"
else
status="FRAGMENTING"
fi
cat >> $GITHUB_STEP_SUMMARY << EOF
## Commit Flow: $status ($score%)
| Metric | Value |
|--------|-------|
| Aligned | $aligned/$total |
| Score | $score% |
| Status | $status |
### Flow Pattern
\`type(scope): description\`
*Maintains persistent clarity through structured commits*
EOF
- name: Open issue
if: steps.flow.outputs.score < 40
run: |
echo "[INFO] Applying gentle flow correction..."
cat > .github/FLOW.md << 'EOF'
# Flow Alignment
Structured commit patterns for consistent development flow.
Pattern: `type(scope): clear description`
EOF
git add .github/FLOW.md
git commit -m "docs(flow): maintain alignment patterns" || true
- name: Check state
run: |
if [ -f "scripts/commit-msg" ] && [ -x "scripts/commit-msg" ]; then
echo "[PASS] Flow validation active"
else
echo "[WARN] Flow validation inactive"
fi