-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgithub-bootstrap.sh
More file actions
executable file
·72 lines (58 loc) · 1.95 KB
/
Copy pathgithub-bootstrap.sh
File metadata and controls
executable file
·72 lines (58 loc) · 1.95 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
#!/usr/bin/env bash
# Create GitHub repo and push code. Does NOT deploy to staging or production.
set -euo pipefail
source "$(dirname "$0")/lib/common.sh"
usage() {
cat <<'EOF'
Usage: github-bootstrap.sh --project <path> --org <github-org-or-user> --repo <repo-name> [--private] [--confirm]
Creates remote repo (via gh), initial commit, and push to GitHub only.
No Cloud Run, no staging URL, no production traffic.
Requires: git, gh (authenticated)
EOF
}
PROJECT=""
ORG=""
REPO=""
PRIVATE="--public"
CONFIRM=""
while [[ $# -gt 0 ]]; do
case "$1" in
--project) PROJECT="$2"; shift 2 ;;
--org) ORG="$2"; shift 2 ;;
--repo) REPO="$2"; shift 2 ;;
--private) PRIVATE="--private"; shift ;;
--confirm) CONFIRM="1"; shift ;;
-h|--help) usage; exit 0 ;;
*) log_fail "Unknown arg: $1"; usage; exit 1 ;;
esac
done
require_confirm "${CONFIRM}" "GitHub bootstrap requires explicit --confirm"
[[ -n "$PROJECT" && -n "$ORG" && -n "$REPO" ]] || { usage; exit 1; }
require_cmd git
require_cmd gh
PROJECT_DIR="$(resolve_project_dir "$PROJECT")"
cd "$PROJECT_DIR"
log_section "Leak scan before GitHub push"
run_leak_scan
log_section "Git + GitHub (no deploy)"
if [[ ! -d .git ]]; then
git init -b main
log_ok "git init (main)"
fi
if ! git remote get-url origin >/dev/null 2>&1; then
gh repo create "${ORG}/${REPO}" ${PRIVATE} --source=. --remote=origin --description "SuperApp project: ${REPO}"
log_ok "Created ${ORG}/${REPO} on GitHub"
else
log_warn "origin remote already exists — skipping gh repo create"
fi
if [[ -z "$(git status --porcelain)" ]] && git rev-parse HEAD >/dev/null 2>&1; then
log_ok "Working tree clean — pushing existing commits"
else
git add -A
git commit -m "chore: initial SuperApp project bootstrap" || true
fi
git push -u origin main
log_ok "Pushed to github.com/${ORG}/${REPO}"
echo ""
log_info "NOT deployed to staging or production."
log_info "Next: use deploy-staging trigger only when you explicitly want cloud traffic."