Files
dbis_docs/git-credential-helper.sh
2025-12-07 10:53:30 -08:00

31 lines
725 B
Bash
Executable File

#!/bin/bash
# Git credential helper that uses GITHUB_TOKEN from .env file
if [ "$1" = get ]; then
# Load .env if it exists
if [ -f .env ]; then
export $(grep -v '^#' .env | xargs)
fi
# Read the input
protocol=""
host=""
path=""
while IFS= read -r line; do
case "$line" in
protocol=*) protocol="${line#*=}" ;;
host=*) host="${line#*=}" ;;
path=*) path="${line#*=}" ;;
esac
done
# Only handle GitHub HTTPS URLs
if [ "$protocol" = "https" ] && [ "$host" = "github.com" ]; then
if [ -n "$GITHUB_TOKEN" ]; then
echo "username=git"
echo "password=$GITHUB_TOKEN"
fi
fi
fi