#!/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