-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup-github-integration.sh
More file actions
executable file
·132 lines (113 loc) · 3.75 KB
/
setup-github-integration.sh
File metadata and controls
executable file
·132 lines (113 loc) · 3.75 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
#!/bin/bash
# HolmesGPT GitHub Integration Setup Script
# This script helps configure GitHub repository integration for HolmesGPT
echo "🔧 HolmesGPT GitHub Integration Setup"
echo "======================================"
echo
# Check if HolmesGPT is running
echo "1. Checking HolmesGPT service..."
if curl -s http://localhost:8080/api/chat > /dev/null 2>&1; then
echo "✅ HolmesGPT is running on localhost:8080"
else
echo "❌ HolmesGPT is not running. Please start HolmesGPT first."
echo " Run: holmes serve"
exit 1
fi
echo
echo "2. GitHub Setup Requirements"
echo "----------------------------"
echo "To integrate GitHub with HolmesGPT, you need:"
echo "• A GitHub repository (your Flux/GitOps repo)"
echo "• A GitHub Personal Access Token with appropriate permissions"
echo
echo "📖 GitHub Personal Access Token Requirements:"
echo "• For public repositories: 'public_repo' scope"
echo "• For private repositories: 'repo' scope"
echo "• For creating PRs: 'pull_requests:write' scope"
echo
echo "🔗 Create a token at: https://github.com/settings/tokens"
echo
read -p "Press Enter to continue..."
echo
echo "3. Configuration"
echo "----------------"
# Get repository information
read -p "Enter your GitHub repository (format: owner/repo): " REPO_NAME
if [[ -z "$REPO_NAME" ]]; then
echo "❌ Repository name is required"
exit 1
fi
# Get GitHub token
read -s -p "Enter your GitHub Personal Access Token: " GITHUB_TOKEN
echo
if [[ -z "$GITHUB_TOKEN" ]]; then
echo "❌ GitHub token is required"
exit 1
fi
# Get branch (optional)
read -p "Enter the branch to use (default: main): " BRANCH_NAME
BRANCH_NAME=${BRANCH_NAME:-main}
echo
echo "4. Updating Configuration"
echo "-------------------------"
# Update ~/.holmes/config.yaml
HOLMES_CONFIG_DIR="$HOME/.holmes"
HOLMES_CONFIG_FILE="$HOLMES_CONFIG_DIR/config.yaml"
# Create config file
cat > "$HOLMES_CONFIG_FILE" << EOF
toolsets:
git:
enabled: true
config:
git_repo: "$REPO_NAME"
git_credentials: "$GITHUB_TOKEN"
git_branch: "$BRANCH_NAME"
EOF
echo "✅ Configuration saved to $HOLMES_CONFIG_FILE"
# Set environment variables for the session
export GIT_REPO="$REPO_NAME"
export GIT_CREDENTIALS="$GITHUB_TOKEN"
export GIT_BRANCH="$BRANCH_NAME"
echo
echo "5. Refreshing HolmesGPT Toolsets"
echo "--------------------------------"
echo "Running: holmes toolset refresh"
if command -v holmes >/dev/null 2>&1; then
holmes toolset refresh
echo "✅ Toolsets refreshed successfully"
else
echo "⚠️ 'holmes' command not found. Please run manually:"
echo " holmes toolset refresh"
fi
echo
echo "6. Testing Configuration"
echo "------------------------"
echo "Testing GitHub integration..."
if command -v holmes >/dev/null 2>&1; then
echo "Running: holmes ask 'List the files in the GitHub repository and read the README file'"
holmes ask "List the files in the GitHub repository and read the README file"
else
echo "⚠️ Please test manually by running:"
echo " holmes ask 'List the files in the GitHub repository and read the README file'"
fi
echo
echo "🎉 Setup Complete!"
echo "=================="
echo
echo "Configuration Summary:"
echo "• Repository: $REPO_NAME"
echo "• Branch: $BRANCH_NAME"
echo "• Config file: $HOLMES_CONFIG_FILE"
echo
echo "Your Slack bot will now:"
echo "• Analyze issues with GitHub repository context"
echo "• Reference your Flux configurations"
echo "• Check commit history for related changes"
echo "• Suggest fixes based on repository best practices"
echo
echo "Next steps:"
echo "1. Restart your Slack bot: npm start"
echo "2. Test with a question like: '@bot deployment issues'"
echo "3. Use /k8s-debug command for enhanced analysis"
echo
echo "🔧 To update the configuration later, edit: $HOLMES_CONFIG_FILE"