main
1#!/usr/bin/env bash
2# Clone work repositories on kyushu (idempotent)
3# Run after SSH keys (TPM + FIDO2) are set up and gh auth is done
4set -euo pipefail
5
6clone_or_check() {
7 local path="$1" origin="$2"
8 shift 2
9 # Remaining args are pairs: remote_name remote_url
10 if [[ -d "$path/.git" ]]; then
11 echo "✓ $path (exists)"
12 # Ensure origin is correct
13 local current
14 current=$(git -C "$path" remote get-url origin 2>/dev/null || true)
15 if [[ "$current" != "$origin" ]]; then
16 echo " ⚠ origin mismatch: $current → $origin"
17 git -C "$path" remote set-url origin "$origin"
18 fi
19 else
20 mkdir -p "$(dirname "$path")"
21 echo "⊕ $path ← $origin"
22 git clone "$origin" "$path" || echo " ✗ clone failed (skipped)"
23 fi
24 # Add/update extra remotes
25 while [[ $# -ge 2 ]]; do
26 local name="$1" url="$2"
27 shift 2
28 local current
29 current=$(git -C "$path" remote get-url "$name" 2>/dev/null || true)
30 if [[ -z "$current" ]]; then
31 echo " + remote $name → $url"
32 git -C "$path" remote add "$name" "$url"
33 elif [[ "$current" != "$url" ]]; then
34 echo " ⚠ $name mismatch: $current → $url"
35 git -C "$path" remote set-url "$name" "$url"
36 fi
37 done
38}
39
40echo "Setting up ~/src/ repositories..."
41echo
42
43# --- Home infra (carthage) ---
44clone_or_check ~/src/home \
45 "https://git.sbr.pm/home.git"
46# Add SSH push URL for home (pull via https, push via SSH)
47if [[ -d ~/src/home/.git ]]; then
48 git -C ~/src/home remote set-url --push origin "vincent@carthage.vpn:/home/vincent/git/public/home.git"
49fi
50clone_or_check ~/src/www \
51 "vincent@carthage.vpn:git/public/www.git"
52
53# --- Praetorian ---
54clone_or_check ~/src/vdemeester/praetorian \
55 "git@github.com:vdemeester/praetorian.git"
56
57# --- OpenShift Pipelines (osp) ---
58osp_repos=(
59 ai-approver ambient-workflows architecture catalog-cd cfp-radar
60 console-plugin cookbook coverage-dashboard docs ecosystem-images
61 hack knowledge-base manual-approval-gate multi-cluster
62 multicluster-proxy-aae must-gather osp-component-dashboard
63 plumbing skills tekton-assist tekton-kueue tkn-autogenerate
64)
65for repo in "${osp_repos[@]}"; do
66 clone_or_check ~/src/osp/"$repo" \
67 "git@github.com:vdemeester/openshift-pipelines-${repo}.git" \
68 upstream "https://github.com/openshift-pipelines/${repo}.git"
69done
70clone_or_check ~/src/osp/opc \
71 "https://github.com/vdemeester/openshift-pipelines-opc.git" \
72 upstream "https://github.com/openshift-pipelines/opc.git"
73
74# --- Tekton upstream ---
75tektoncd_repos=(
76 actions catalog catlin chains cli community dashboard
77 mcp-server operator pipeline plumbing pruner results triggers website
78)
79for repo in "${tektoncd_repos[@]}"; do
80 clone_or_check ~/src/tektoncd/"$repo" \
81 "git@github.com:vdemeester/tektoncd-${repo}.git" \
82 upstream "https://github.com/tektoncd/${repo}.git"
83done
84clone_or_check ~/src/tektoncd/pipelines-as-code \
85 "git@github.com:vdemeester/pipelines-as-code.git" \
86 upstream "https://github.com/tektoncd/pipelines-as-code.git"
87clone_or_check ~/src/tektoncd/infra \
88 "https://github.com/tektoncd/infra.git"
89clone_or_check ~/src/tektoncd/.github \
90 "https://github.com/vdemeester/tektoncd-dotgithub.git" \
91 upstream "https://github.com/tektoncd/.github.git"
92clone_or_check ~/src/tektoncd/docusaurus-poc \
93 "https://github.com/vdemeester/tekton-docusaurus-poc.git"
94clone_or_check ~/src/tektoncd/upstream-highlights \
95 "https://github.com/vdemeester/upstream-highlights.git"
96
97# --- Tekton catalog repos ---
98tektoncd_catalog_repos=(git-clone golang kaniko)
99for repo in "${tektoncd_catalog_repos[@]}"; do
100 clone_or_check ~/src/tektoncd-catalog/"$repo" \
101 "git@github.com:vdemeester/tektoncd-catalog-${repo}.git" \
102 upstream "https://github.com/tektoncd-catalog/${repo}.git"
103done
104
105# --- Other ---
106clone_or_check ~/src/carlos/pipelines-lab \
107 "https://github.com/carlos-salinas/pipelines-lab"
108
109echo
110echo "Done! $(find ~/src -name '.git' -type d | wc -l) repos in ~/src/"