OSVauco/scripts/osv-github-auth.sh

49 lines
1.4 KiB
Bash
Executable File
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#!/usr/bin/env bash
# OSVauco GitHub auth helper sjekker gh-status på en ryddig måte
set -euo pipefail
GREEN="$(tput setaf 2 || true)"
RED="$(tput setaf 1 || true)"
YELLOW="$(tput setaf 3 || true)"
BLUE="$(tput setaf 4 || true)"
BOLD="$(tput bold || true)"
RESET="$(tput sgr0 || true)"
clear || true
echo "============================================================"
echo " ${BOLD}O S V A U C O · G I T H U B${RESET}"
echo "============================================================"
echo
if ! command -v gh >/dev/null 2>&1; then
echo " ${RED}❌ 'gh' (GitHub CLI) er ikke installert i denne miljøet.${RESET}"
echo " Installer via package manager hvis du trenger avansert GitHub-støtte."
exit 1
fi
if gh auth status >/dev/null 2>&1; then
echo " ${GREEN}✅ GitHub: gh auth status = OK${RESET}"
gh auth status
else
echo " ${YELLOW}⚠️ gh er ikke logget inn for denne shellen.${RESET}"
echo
read -r -p "[OSVauco/GH] Kjøre 'gh auth login' nå? (y/N): " ANSWER
case "$ANSWER" in
y|Y)
echo
gh auth login
echo
if gh auth status >/dev/null 2>&1; then
echo " ${GREEN}✅ GitHub: innlogging OK etter gh auth login.${RESET}"
else
echo " ${RED}❌ GitHub: fortsatt ikke logget inn sjekk token/bruker.${RESET}"
fi
;;
*)
echo " ${YELLOW}OK, gjør det senere manuelt med 'gh auth login'.${RESET}"
;;
esac
fi