Files
at2-workstation-scripts/gitea_push_debug.sh
2025-04-12 09:56:11 +02:00

47 lines
1.2 KiB
Bash
Executable File

#!/bin/zsh
# Script Version: 1.0 Debug
# Description: Extended debug version of Gitea push script for diagnosing issues.
# 1) Basic variables
GITEA_USER="oib"
GITEA_URL="https://gitea.bubuit.net"
GITEA_API_URL="$GITEA_URL/api/v1"
# 2) Debug function
log_debug() {
echo "[DEBUG] $@"
}
log_debug "== Starting gitea_push_debug.sh =="
# 3) Show environment
log_debug "Home Dir: $HOME"
log_debug "PWD: $PWD"
log_debug "User: $USER"
# 4) Check GITEA_API_TOKEN from environment
if [ -z "$GITEA_API_TOKEN" ]; then
log_debug "GITEA_API_TOKEN is not set in environment"
else
log_debug "GITEA_API_TOKEN is present, length: ${#GITEA_API_TOKEN}"
fi
# 5) Attempt to read from ~/.gitea_token
if [ -f "$HOME/.gitea_token" ]; then
TOKEN_FILE_CONTENT=$(cat "$HOME/.gitea_token")
log_debug "~/.gitea_token found, length: ${#TOKEN_FILE_CONTENT}"
else
log_debug "~/.gitea_token not found"
fi
# 6) Try an API request to /user with the token from environment
if [ -n "$GITEA_API_TOKEN" ]; then
USER_RESPONSE=$(curl -s -H "Authorization: token $GITEA_API_TOKEN" "$GITEA_API_URL/user")
log_debug "Response from /user: $USER_RESPONSE"
else
log_debug "Skipping /user request; no valid GITEA_API_TOKEN in environment."
fi
log_debug "== End gitea_push_debug.sh =="