feat: mirror-to-github.sh på VM
Some checks are pending
Check Python Version Consistency / Check Python Version (push) Waiting to run
Some checks are pending
Check Python Version Consistency / Check Python Version (push) Waiting to run
This commit is contained in:
parent
ba8185cac2
commit
7c87a8ab8f
17
scripts/mirror-to-github.sh
Executable file
17
scripts/mirror-to-github.sh
Executable file
|
|
@ -0,0 +1,17 @@
|
|||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
OSVAUCO_DIR="${OSVAUCO_DIR:-$HOME/OSVauco}"
|
||||
GOOGLE_CLOUD_PROJECT="${GOOGLE_CLOUD_PROJECT:-propane-will-491900-m5}"
|
||||
GITHUB_REPO="https://github.com/vauco-saas/OSVauco.git"
|
||||
cd "$OSVAUCO_DIR"
|
||||
if [[ -z "${GITHUB_TOKEN:-}" ]]; then
|
||||
GITHUB_TOKEN=$(gcloud secrets versions access latest
|
||||
--secret="github-token" --project="$GOOGLE_CLOUD_PROJECT" 2>/dev/null || echo "")
|
||||
[[ -z "$GITHUB_TOKEN" ]] && echo "ERROR: github-token mangler" && exit 1
|
||||
export GITHUB_TOKEN
|
||||
fi
|
||||
GITHUB_URL="https://x-access-token:${GITHUB_TOKEN}@github.com/vauco-saas/OSVauco.git"
|
||||
git remote get-url github &>/dev/null && git remote set-url github "$GITHUB_URL" || git remote add github "$GITHUB_URL"
|
||||
BRANCH=$(git branch --show-current 2>/dev/null || echo "main")
|
||||
git push github "${BRANCH}:${BRANCH}" --force && echo "✅ Speilet til GitHub"
|
||||
git remote set-url github "$GITHUB_REPO"
|
||||
Loading…
Reference in New Issue
Block a user