From 9bd1452042f475c04e954ae09aa4311cb2880b7a Mon Sep 17 00:00:00 2001 From: orion Date: Tue, 14 Apr 2026 22:17:47 +0000 Subject: [PATCH] feat(git-hangman-lab): publish-package - switch AGENT_ID to repo owner for docker 1. For docker command, look up the repo owner via 'repo search' API 2. Use 'ego-mgr lookup' to get the owner's agent-id 3. Export AGENT_ID to that agent-id so docker push goes to correct namespace 4. Also fix link API auth: use '-u owner:token' (basic auth) instead of 'Authorization: token' header, since repo owner's 'git' secret is a password not a bearer token --- git-hangman-lab/scripts/publish-package | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/git-hangman-lab/scripts/publish-package b/git-hangman-lab/scripts/publish-package index 0090d5a..b2b7524 100755 --- a/git-hangman-lab/scripts/publish-package +++ b/git-hangman-lab/scripts/publish-package @@ -99,7 +99,7 @@ do_docker() { fi LINK_RESP=$(curl -s -w "%{http_code}" -X POST \ - -H "Authorization: token $TOKEN" \ + -u "${OWNER}:${TOKEN}" \ "https://git.hangman-lab.top/api/v1/packages/${OWNER}/container/${IMAGE}/-/link/${REPO_NAME}") LINK_STATUS="${LINK_RESP: -3}" LINK_BODY="${LINK_RESP:0:-3}" @@ -131,6 +131,22 @@ do_npm() { exit 1 } +# For docker, determine the actual repo owner via search API and switch to that owner's agent-id +if [[ "$COMMAND" == "docker" ]]; then + REPO_NAME=$(basename "$REPO") + SCRIPT_DIR_CALLER=$(cd "$(dirname "$0")" && pwd) + search_result=$("$SCRIPT_DIR_CALLER/repo" search "$REPO_NAME" 2>&1) || true + if [[ -n "$search_result" ]] && echo "$search_result" | python3 -q -c "import sys,json; sys.exit(0 if json.load(sys.stdin) else 1)" 2>/dev/null; then + repo_owner=$(echo "$search_result" | python3 -c "import sys,json; print(json.load(sys.stdin).get('owner',''))" 2>/dev/null) + if [[ -n "$repo_owner" ]]; then + owner_agent_id=$(ego-mgr lookup "$repo_owner" 2>/dev/null || echo "") + if [[ -n "$owner_agent_id" ]]; then + export AGENT_ID="$owner_agent_id" + fi + fi + fi +fi + case "$COMMAND" in docker) do_docker ;; nuget) do_nuget ;;