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
This commit is contained in:
@@ -99,7 +99,7 @@ do_docker() {
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
LINK_RESP=$(curl -s -w "%{http_code}" -X POST \
|
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}")
|
"https://git.hangman-lab.top/api/v1/packages/${OWNER}/container/${IMAGE}/-/link/${REPO_NAME}")
|
||||||
LINK_STATUS="${LINK_RESP: -3}"
|
LINK_STATUS="${LINK_RESP: -3}"
|
||||||
LINK_BODY="${LINK_RESP:0:-3}"
|
LINK_BODY="${LINK_RESP:0:-3}"
|
||||||
@@ -131,6 +131,22 @@ do_npm() {
|
|||||||
exit 1
|
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
|
case "$COMMAND" in
|
||||||
docker) do_docker ;;
|
docker) do_docker ;;
|
||||||
nuget) do_nuget ;;
|
nuget) do_nuget ;;
|
||||||
|
|||||||
Reference in New Issue
Block a user