Adding the skills
This commit is contained in:
+12
-31
@@ -1,12 +1,4 @@
|
||||
#!/bin/bash
|
||||
# Sets up git remotes for all glitch-component folders and pushes to ramanujan.
|
||||
#
|
||||
# Usage:
|
||||
# ./setup-remotes.sh # set remotes only
|
||||
# ./setup-remotes.sh --push # set remotes and push all
|
||||
#
|
||||
# Reads GIT_USER / GIT_PASSWORD from ../.env if present, otherwise prompts.
|
||||
|
||||
set -e
|
||||
|
||||
REMOTE_HOST="ramanujan.glitch.university"
|
||||
@@ -14,34 +6,17 @@ COMPONENTS_DIR="$(cd "$(dirname "$0")" && pwd)"
|
||||
PUSH=false
|
||||
[[ "$1" == "--push" ]] && PUSH=true
|
||||
|
||||
# ── Load credentials ──────────────────────────────────────────────────────────
|
||||
REMOTE_BASE="ssh://git@${REMOTE_HOST}/git/repos"
|
||||
|
||||
ENV_FILE="$COMPONENTS_DIR/../gnommoweb/.env.prod"
|
||||
if [ -f "$ENV_FILE" ]; then
|
||||
GIT_USER=$(grep -E '^GIT_USER=' "$ENV_FILE" | cut -d= -f2 | tr -d '"'"'" | head -1)
|
||||
GIT_PASSWORD=$(grep -E '^GIT_PASSWORD=' "$ENV_FILE" | cut -d= -f2 | tr -d '"'"'" | head -1)
|
||||
fi
|
||||
|
||||
if [ -z "$GIT_USER" ] || [ -z "$GIT_PASSWORD" ]; then
|
||||
read -rp "Git username: " GIT_USER
|
||||
read -rsp "Git password: " GIT_PASSWORD
|
||||
echo
|
||||
fi
|
||||
|
||||
REMOTE_BASE="https://${GIT_USER}:${GIT_PASSWORD}@${REMOTE_HOST}"
|
||||
|
||||
# ── Process each component folder ─────────────────────────────────────────────
|
||||
|
||||
for dir in "$COMPONENTS_DIR"/*/; do
|
||||
name=$(basename "$dir")
|
||||
|
||||
# Skip the skills folder and any non-component entries
|
||||
[[ "$name" == "skills" ]] && continue
|
||||
|
||||
echo "── $name"
|
||||
cd "$dir"
|
||||
|
||||
# Init if not already a git repo
|
||||
if [ ! -d ".git" ]; then
|
||||
git init -q
|
||||
git add -A
|
||||
@@ -49,21 +24,27 @@ for dir in "$COMPONENTS_DIR"/*/; do
|
||||
echo " initialised"
|
||||
fi
|
||||
|
||||
# Add or update remote
|
||||
REMOTE_URL="https://${REMOTE_HOST}/${name}.git"
|
||||
|
||||
if git remote get-url origin &>/dev/null; then
|
||||
git remote set-url origin "${REMOTE_BASE}/${name}.git"
|
||||
git remote set-url origin "$REMOTE_URL"
|
||||
echo " remote updated"
|
||||
else
|
||||
git remote add origin "${REMOTE_BASE}/${name}.git"
|
||||
git remote add origin "$REMOTE_URL"
|
||||
echo " remote added"
|
||||
fi
|
||||
|
||||
# Push
|
||||
if $PUSH; then
|
||||
if ssh git@"$REMOTE_HOST" create-repo "${name}.git" 2>/dev/null; then
|
||||
echo " remote repo ensured"
|
||||
else
|
||||
echo " remote repo may already exist"
|
||||
fi
|
||||
|
||||
if git push -u origin main -q 2>/dev/null || git push -u origin master:main -q 2>/dev/null; then
|
||||
echo " pushed"
|
||||
else
|
||||
echo " push failed (repo may not exist on server yet)"
|
||||
echo " push failed"
|
||||
fi
|
||||
fi
|
||||
|
||||
|
||||
Reference in New Issue
Block a user