-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconfigure.sh
More file actions
executable file
·57 lines (46 loc) · 1.56 KB
/
configure.sh
File metadata and controls
executable file
·57 lines (46 loc) · 1.56 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
#!/bin/bash
# Configuration script for GitHub Branch Analyzer
# This script sets up the environment variables needed for the analyzer
# Check if .env file exists and source it if it does
if [ -f .env ]; then
source .env
fi
# Function to prompt for input with a default value
prompt_with_default() {
local prompt=$1
local default=$2
local input
echo -n "$prompt [$default]: "
read input
echo "${input:-$default}"
}
# Prompt for GitHub token if not set
if [ -z "$GITHUB_TOKEN" ]; then
echo "GitHub Personal Access Token is required to access private repositories."
echo "You can create one at: https://github.com/settings/tokens"
echo "Ensure it has 'repo' permissions to access private repositories."
read -p "Enter your GitHub Personal Access Token: " GITHUB_TOKEN
fi
# Prompt for repository name if not set
if [ -z "$GITHUB_REPO" ]; then
GITHUB_REPO=$(prompt_with_default "Enter repository name (format: owner/repo)" "")
fi
# Prompt for branch names
MAIN_BRANCH=$(prompt_with_default "Enter main branch name" "main")
RELEASE_BRANCH=$(prompt_with_default "Enter release branch name" "release")
# Save to .env file
cat > .env << EOF
GITHUB_TOKEN=$GITHUB_TOKEN
GITHUB_REPO=$GITHUB_REPO
MAIN_BRANCH=$MAIN_BRANCH
RELEASE_BRANCH=$RELEASE_BRANCH
EOF
echo "Configuration saved to .env file"
echo "To run the analyzer, use: python github_branch_analyzer.py"
# Make the .env file readable only by the owner
chmod 600 .env
# Export variables for immediate use
export GITHUB_TOKEN
export GITHUB_REPO
export MAIN_BRANCH
export RELEASE_BRANCH