-
Notifications
You must be signed in to change notification settings - Fork 46
Expand file tree
/
Copy pathbootstrap.sh
More file actions
executable file
·111 lines (94 loc) · 3.43 KB
/
Copy pathbootstrap.sh
File metadata and controls
executable file
·111 lines (94 loc) · 3.43 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
#!/usr/bin/env bash
set -euo pipefail
usage() {
cat <<'EOF'
Usage: bash bootstrap.sh [repo-name]
Creates your own private copy of the course repo on GitHub, invites your
teammates as collaborators, and prints the URL plus next steps.
Arguments:
repo-name Name for your private repo (default: agentic-engineering-private)
Options:
-h, --help Show this help message and exit
EOF
}
REPO_NAME="agentic-engineering-private"
for arg in "$@"; do
case "$arg" in
-h|--help)
usage
exit 0
;;
esac
done
if [ "$#" -gt 0 ]; then
REPO_NAME="$1"
fi
echo "==> Checking required tools (git, gh)..."
command -v git >/dev/null 2>&1 || { echo "error: git is required but not found" >&2; exit 1; }
command -v gh >/dev/null 2>&1 || { echo "error: gh (GitHub CLI) is required but not found" >&2; exit 1; }
echo "==> Checking GitHub CLI authentication..."
if ! gh auth status >/dev/null 2>&1; then
echo "run: gh auth login"
exit 1
fi
echo "==> Locating the course repo..."
IN_COURSE_CLONE=false
if TOPLEVEL="$(git rev-parse --show-toplevel 2>/dev/null)"; then
if git -C "$TOPLEVEL" remote -v 2>/dev/null | grep -q "NickGuAI/agentic-engineering-course"; then
IN_COURSE_CLONE=true
fi
fi
if [ "$IN_COURSE_CLONE" = true ]; then
echo " already inside a clone of the course repo; using it."
cd "$TOPLEVEL"
else
echo " cloning the course repo into ./$REPO_NAME ..."
git clone https://github.com/NickGuAI/agentic-engineering-course.git "$REPO_NAME"
cd "$REPO_NAME"
fi
echo "==> Setting up the 'upstream' remote..."
if git remote | grep -qx "upstream"; then
echo " 'upstream' remote already exists; leaving it as-is."
else
git remote rename origin upstream
echo " renamed 'origin' to 'upstream'."
fi
GH_LOGIN="$(gh api user -q .login)"
echo "==> Creating your private GitHub repo..."
ORIGIN_IS_PRIVATE=false
if git remote | grep -qx "origin"; then
if PRIVATE="$(gh repo view "$(git remote get-url origin)" --json isPrivate -q .isPrivate 2>/dev/null)" && [ "$PRIVATE" = "true" ]; then
ORIGIN_IS_PRIVATE=true
fi
fi
if [ "$ORIGIN_IS_PRIVATE" = true ]; then
echo " 'origin' already points to a private repo; pushing instead of creating."
git push -u origin HEAD
else
if gh repo view "$GH_LOGIN/$REPO_NAME" >/dev/null 2>&1; then
echo "error: you already have a repo named $GH_LOGIN/$REPO_NAME." >&2
echo " pick another name: bash bootstrap.sh my-agentic-engineering" >&2
exit 1
fi
gh repo create "$REPO_NAME" --private --source=. --remote=origin --push
fi
echo "==> Inviting the instructor and TAs to your repo..."
# Name the student's repo explicitly: with both 'origin' and 'upstream' remotes
# present, gh's {owner}/{repo} placeholder can resolve to the course repo instead.
STUDENT_REPO="$(git remote get-url origin | sed -E 's#^(https://github.com/|git@github.com:)##; s#\.git$##')"
for id in NickGuAI arielbenavi thevoid12 vineet-channe; do
if gh api -X PUT "repos/$STUDENT_REPO/collaborators/$id" -f permission=push >/dev/null 2>&1; then
echo " ok: $id"
else
echo " skipped: $id (invite failed; note the owner cannot invite themself)"
fi
done
REPO_URL="$(git remote get-url origin)"
REPO_URL="${REPO_URL%.git}"
if [[ "$REPO_URL" == git@github.com:* ]]; then
REPO_URL="https://github.com/${REPO_URL#git@github.com:}"
fi
echo ""
echo "$REPO_URL"
echo "Add your teammates: Settings > Collaborators"
echo "Course materials sync daily via GitHub Actions; run 'git pull upstream main' to sync now."