27 lines
735 B
Bash
Executable File
27 lines
735 B
Bash
Executable File
#!/usr/bin/env bash
|
|
set -euo pipefail
|
|
|
|
ROOT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
|
|
SECRET_FILE="$ROOT_DIR/.secrets/mirror.env"
|
|
|
|
if [[ ! -f "$SECRET_FILE" ]]; then
|
|
echo "Missing secrets file: $SECRET_FILE" >&2
|
|
exit 1
|
|
fi
|
|
|
|
# shellcheck disable=SC1090
|
|
source "$SECRET_FILE"
|
|
|
|
: "${MIRROR_USER:?MIRROR_USER is required}"
|
|
: "${MIRROR_TOKEN:?MIRROR_TOKEN is required}"
|
|
: "${MIRROR_URL:?MIRROR_URL is required}"
|
|
|
|
if ! git remote get-url mirror >/dev/null 2>&1; then
|
|
git remote add mirror "$MIRROR_URL"
|
|
else
|
|
git remote set-url mirror "$MIRROR_URL"
|
|
fi
|
|
|
|
auth="$(printf '%s' "$MIRROR_USER:$MIRROR_TOKEN" | base64 -w0)"
|
|
git -c http.https://git.andersentech.com/.extraheader="AUTHORIZATION: basic $auth" push mirror main:main
|