63 lines
1.6 KiB
Bash
Executable File
63 lines
1.6 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
set -euo pipefail
|
|
|
|
if [[ $# -lt 1 ]]; then
|
|
echo "Usage: $0 <gitea_pat> [org] [host]" >&2
|
|
exit 1
|
|
fi
|
|
|
|
TOKEN="$1"
|
|
ORG="${2:-edut}"
|
|
HOST="${3:-git.workvsg.com}"
|
|
ROOT="/Users/vsg/Documents/VSG Codex"
|
|
|
|
create_repo() {
|
|
local name="$1"
|
|
local private="$2"
|
|
local desc="$3"
|
|
|
|
local api="https://${HOST}/api/v1/repos/${ORG}/${name}"
|
|
local status
|
|
status=$(curl -sS -o /tmp/repo_check_${name}.json -w "%{http_code}" \
|
|
-H "Authorization: token ${TOKEN}" \
|
|
"$api")
|
|
|
|
if [[ "$status" == "200" ]]; then
|
|
echo "Repo ${ORG}/${name} already exists"
|
|
return
|
|
fi
|
|
|
|
curl -fsSL \
|
|
-H "Authorization: token ${TOKEN}" \
|
|
-H 'Content-Type: application/json' \
|
|
-X POST "https://${HOST}/api/v1/orgs/${ORG}/repos" \
|
|
-d "{\"name\":\"${name}\",\"private\":${private},\"description\":\"${desc}\"}" >/tmp/repo_create_${name}.json
|
|
|
|
echo "Created repo ${ORG}/${name}"
|
|
}
|
|
|
|
wire_and_push() {
|
|
local local_dir="$1"
|
|
local name="$2"
|
|
local remote_url="https://${HOST}/${ORG}/${name}.git"
|
|
|
|
cd "$local_dir"
|
|
if ! git remote | grep -q '^origin$'; then
|
|
git remote add origin "$remote_url"
|
|
else
|
|
git remote set-url origin "$remote_url"
|
|
fi
|
|
git push -u origin main
|
|
echo "Pushed ${local_dir} -> ${remote_url}"
|
|
}
|
|
|
|
create_repo "launcher" "true" "EDUT free launcher shell and wallet onboarding app"
|
|
create_repo "governance" "true" "EDUT deterministic governance runtime"
|
|
create_repo "contracts" "false" "EDUT membership and entitlement contracts"
|
|
|
|
wire_and_push "${ROOT}/launcher" "launcher"
|
|
wire_and_push "${ROOT}/governance" "governance"
|
|
wire_and_push "${ROOT}/contracts" "contracts"
|
|
|
|
echo "Split repo publish complete"
|