-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathsetup-github.sh
More file actions
executable file
·84 lines (75 loc) · 2.81 KB
/
setup-github.sh
File metadata and controls
executable file
·84 lines (75 loc) · 2.81 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
#!/bin/bash
# GitHub Setup Script for Dev Container
# This script helps you connect to GitHub from your dev environment
echo "GitHub Setup for Dev Container"
echo "==============================="
echo ""
echo "Choose your preferred method:"
echo "1) Install GitHub CLI (gh) - Recommended"
echo "2) Generate SSH key for GitHub"
echo "3) Both"
echo ""
read -p "Enter choice [1-3]: " choice
POD_NAME=$(kubectl get pods -n coder -l app=ws-imran -o jsonpath='{.items[0].metadata.name}')
case $choice in
1)
echo "Installing GitHub CLI..."
kubectl exec -it $POD_NAME -n coder -c ide -- bash -c '
# Install GitHub CLI
curl -fsSL https://cli.github.com/packages/githubcli-archive-keyring.gpg | sudo dd of=/usr/share/keyrings/githubcli-archive-keyring.gpg
echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/githubcli-archive-keyring.gpg] https://cli.github.com/packages stable main" | sudo tee /etc/apt/sources.list.d/github-cli.list > /dev/null
sudo apt update
sudo apt install gh -y
echo ""
echo "GitHub CLI installed! Now run:"
echo " gh auth login"
echo ""
echo "Choose:"
echo " - GitHub.com"
echo " - HTTPS"
echo " - Login with a web browser (or paste token)"
'
;;
2)
echo "Generating SSH key..."
kubectl exec -it $POD_NAME -n coder -c ide -- bash -c '
# Generate SSH key
mkdir -p ~/.ssh
ssh-keygen -t ed25519 -C "imran@scalebase.io" -f ~/.ssh/id_ed25519 -N ""
# Start ssh-agent
eval "$(ssh-agent -s)"
ssh-add ~/.ssh/id_ed25519
# Display the public key
echo ""
echo "Your SSH public key (copy this to GitHub):"
echo "=========================================="
cat ~/.ssh/id_ed25519.pub
echo "=========================================="
echo ""
echo "Add this key to GitHub:"
echo "1. Go to https://github.com/settings/keys"
echo "2. Click \"New SSH Key\""
echo "3. Paste the key above"
echo ""
# Configure git
git config --global user.name "Imran Ali"
git config --global user.email "imran@scalebase.io"
'
;;
3)
# Run both options
$0 <<< "1"
$0 <<< "2"
;;
*)
echo "Invalid choice"
exit 1
;;
esac
echo ""
echo "To connect to your dev container and use git:"
echo " kubectl exec -it $POD_NAME -n coder -c ide -- bash"
echo ""
echo "Or access via terminal:"
echo " https://imran.dev.scalebase.io/terminal/"
echo " (login with admin:kiwiisthequeen)"