forked from chioma-housing-protocol-I/chioma
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcreate-github-issues.sh
More file actions
executable file
·118 lines (97 loc) · 2.92 KB
/
create-github-issues.sh
File metadata and controls
executable file
·118 lines (97 loc) · 2.92 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
#!/bin/bash
# Script to create GitHub issues from markdown files
# Checks for existing issues to avoid duplicates
set -o pipefail
ISSUES_DIR="./issues"
# Function to extract title from markdown file
get_title() {
local file="$1"
grep -m 1 "^# " "$file" | sed 's/^# //'
}
# Function to extract priority from markdown file
get_priority() {
local file="$1"
local priority_line=$(grep "^\*\*Priority:\*\*" "$file" || echo "")
if echo "$priority_line" | grep -q "CRITICAL"; then
echo "priority:critical"
elif echo "$priority_line" | grep -q "HIGH"; then
echo "priority:high"
elif echo "$priority_line" | grep -q "MEDIUM"; then
echo "priority:medium"
else
echo "priority:low"
fi
}
# Function to extract category and convert to labels
get_category_labels() {
local file="$1"
local category_line=$(grep "^\*\*Category:\*\*" "$file" || echo "")
if echo "$category_line" | grep -qi "Security"; then
echo "security"
elif echo "$category_line" | grep -qi "Smart Contract"; then
echo "contract,blockchain"
elif echo "$category_line" | grep -qi "Frontend"; then
echo "frontend,ui"
elif echo "$category_line" | grep -qi "Backend"; then
echo "backend"
elif echo "$category_line" | grep -qi "Code Quality"; then
echo "code-quality"
else
echo ""
fi
}
# Function to check if issue already exists
issue_exists() {
local title="$1"
gh issue list --limit 500 --json title --jq '.[].title' | grep -Fxq "$title" 2>/dev/null
return $?
}
# Counter for created issues
created_count=0
skipped_count=0
echo "Starting GitHub issue creation..."
echo "================================"
echo ""
# Process each markdown file
for file in "$ISSUES_DIR"/*.md; do
# Skip README
if [[ "$file" == *"README.md" ]]; then
continue
fi
# Extract issue details
title=$(get_title "$file")
priority=$(get_priority "$file")
category_labels=$(get_category_labels "$file")
# Combine labels
labels="$priority"
if [ -n "$category_labels" ]; then
labels="$labels,$category_labels"
fi
# Check if issue already exists
if issue_exists "$title"; then
echo "⏭️ SKIPPED: $title (already exists)"
((skipped_count++))
continue
fi
# Create the issue
echo "📝 Creating: $title"
echo " Labels: $labels"
gh issue create \
--title "$title" \
--body-file "$file" \
--label "$labels"
if [ $? -eq 0 ]; then
echo "✅ Created successfully"
((created_count++))
else
echo "❌ Failed to create"
fi
echo ""
# Small delay to avoid rate limiting
sleep 1
done
echo "================================"
echo "Summary:"
echo " Created: $created_count issues"
echo " Skipped: $skipped_count issues (already exist)"
echo "================================"