-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcommit-workflows-all.sh
More file actions
executable file
·177 lines (149 loc) · 4.28 KB
/
Copy pathcommit-workflows-all.sh
File metadata and controls
executable file
·177 lines (149 loc) · 4.28 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
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
#!/bin/bash
#
# Commit and Push Quality Gate Workflows to All Projects
#
# Usage:
# ./commit-workflows-all.sh --all
# ./commit-workflows-all.sh --project ../jcommons
# ./commit-workflows-all.sh --all --dry-run
#
set -e
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
PARENT_DIR="$(dirname "$SCRIPT_DIR")"
DRY_RUN=false
TARGET_PROJECT=""
APPLY_ALL=false
# Parse arguments
while [[ $# -gt 0 ]]; do
case $1 in
--all)
APPLY_ALL=true
shift
;;
--project)
TARGET_PROJECT="$2"
shift 2
;;
--dry-run)
DRY_RUN=true
shift
;;
*)
echo "Unknown option: $1"
echo "Usage: $0 [--all | --project <path>] [--dry-run]"
exit 1
;;
esac
done
if [[ "$APPLY_ALL" == false && -z "$TARGET_PROJECT" ]]; then
echo "Error: Must specify --all or --project <path>"
exit 1
fi
echo "========================================"
echo "Commit and Push Quality Gate Workflows"
echo "========================================"
echo "Dry Run: $DRY_RUN"
echo
commit_and_push() {
local project_dir="$1"
local project_name=$(basename "$project_dir")
echo "📦 Processing: $project_name"
# Check if .github directory exists
if [[ ! -d "$project_dir/.github" ]]; then
echo " ⚠️ SKIPPED - No .github directory found"
echo
return
fi
# Check if workflow file exists
if [[ ! -f "$project_dir/.github/workflows/quality-gate.yml" ]]; then
echo " ⚠️ SKIPPED - No quality-gate.yml found"
echo
return
fi
cd "$project_dir"
# Check if git repo
if [[ ! -d ".git" ]]; then
echo " ⚠️ SKIPPED - Not a git repository"
echo
return
fi
# Check if changes exist
if ! git status --porcelain | grep -q ".github/"; then
echo " ℹ️ SKIPPED - No changes to commit"
echo
return
fi
if [[ "$DRY_RUN" == true ]]; then
echo " ℹ️ Would commit and push .github/ (dry run)"
git status --short .github/
echo
return
fi
# Add .github directory
git add .github/
# Commit
git commit -m "$(cat <<'EOF'
Add automated quality gate workflow
Enables automated quality monitoring with GitHub Actions:
- Auto-creates issues when quality checks fail
- Comments quality metrics on PRs
- Daily security scans (2 AM UTC)
- Prevents merging failing PRs
Quality Gates:
- JaCoCo: ≥93% instruction, ≥86% branch coverage
- SpotBugs: 0 bugs
- PMD: 0 violations
- Checkstyle: 0 errors
- OWASP: 0 critical/high vulnerabilities
Issues auto-labeled: quality-gate, automated, [tool-specific]
See .github/README.md for details.
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
EOF
)"
# Push
if git push; then
echo " ✅ Committed and pushed"
else
echo " ❌ Failed to push (check permissions/remote)"
fi
echo
}
# Find and process projects
if [[ "$APPLY_ALL" == true ]]; then
echo "Searching for projects with .github/ in: $PARENT_DIR"
echo
find "$PARENT_DIR" -maxdepth 2 -type d -name ".github" | while read -r github_dir; do
project_dir="$(dirname "$github_dir")"
# Skip build-tools itself
if [[ "$project_dir" == "$SCRIPT_DIR" ]]; then
continue
fi
commit_and_push "$project_dir"
done
else
# Apply to specific project
if [[ ! -d "$TARGET_PROJECT" ]]; then
echo "Error: Directory not found: $TARGET_PROJECT"
exit 1
fi
commit_and_push "$TARGET_PROJECT"
fi
echo "========================================"
echo "Summary"
echo "========================================"
if [[ "$DRY_RUN" == true ]]; then
echo "Dry run complete. No changes made."
else
echo "Quality gate workflows committed and pushed!"
echo
echo "✅ Next Steps:"
echo " 1. Check GitHub Actions tab in each repo"
echo " 2. Workflow runs on next code push"
echo " 3. Monitor for auto-created issues (quality-gate label)"
echo
echo "📊 Monitor Quality:"
echo " - GitHub → Actions tab (see workflow runs)"
echo " - GitHub → Issues → Labels → quality-gate"
echo " - PRs will have quality metric comments"
fi
echo