fix: use Woodpecker v3 numeric repo IDs in API calls

Woodpecker v3 requires numeric repo IDs in API endpoints, not
owner/repo path segments. The old paths hit the SPA frontend
catch-all and return HTML, which downstream tools misinterpret
as auth failure (401).

- Add tools/woodpecker/_lib.sh with wp_resolve_repo_id() helper
  that calls /api/repos/lookup/{owner}/{repo} to get numeric ID
- Update all 3 pipeline scripts to resolve repo ID before API calls

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Jason Woltje
2026-02-23 12:54:03 -06:00
parent 93efbcdafe
commit 364d6c2278
4 changed files with 69 additions and 25 deletions

View File

@@ -16,6 +16,7 @@ set -euo pipefail
MOSAIC_HOME="${MOSAIC_HOME:-$HOME/.config/mosaic}"
source "$MOSAIC_HOME/tools/_lib/credentials.sh"
source "$(dirname "${BASH_SOURCE[0]}")/_lib.sh"
REPO=""
NUMBER=""
@@ -40,20 +41,17 @@ else
fi
if [[ -z "$REPO" ]]; then
remote_url=$(git remote get-url origin 2>/dev/null || true)
if [[ -n "$remote_url" ]]; then
REPO=$(echo "$remote_url" | sed -E 's|.*[:/]([^/]+/[^/]+?)(\.git)?$|\1|')
else
echo "Error: -r owner/repo required (not in a git repository)" >&2
exit 1
fi
REPO=$(wp_detect_repo) || exit 1
fi
# Resolve owner/repo to numeric ID (Woodpecker v3 API)
REPO_ID=$(wp_resolve_repo_id "$REPO") || exit 1
if [[ -z "$NUMBER" ]]; then
# Get latest pipeline
endpoint="${WOODPECKER_URL}/api/repos/${REPO}/pipelines?per_page=1"
endpoint="${WOODPECKER_URL}/api/repos/${REPO_ID}/pipelines?per_page=1"
else
endpoint="${WOODPECKER_URL}/api/repos/${REPO}/pipelines/${NUMBER}"
endpoint="${WOODPECKER_URL}/api/repos/${REPO_ID}/pipelines/${NUMBER}"
fi
response=$(curl -sk -w "\n%{http_code}" \