summaryrefslogtreecommitdiffhomepage
path: root/scripts/utils/gh-ready-check
blob: 164b5de903f6c1ea97aedef72b115a0a88b67f03 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
#!/usr/bin/env bash

# This script controls that the gh (GitHub CLI) command is installed and authenticated. This can be
# called in the beginning of all scripts depending on gh.

set -eu

SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
cd "$SCRIPT_DIR"

# shellcheck source=scripts/utils/log
source ./log

if ! command -v gh > /dev/null; then
    log_error "gh (GitHub CLI) is required to run this script"
    exit 1
fi

if ! gh auth status > /dev/null; then
    log_error "Authentication through gh (GitHub CLI) is required to run this script"
    exit 1
fi