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

@@ -15,6 +15,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=""
BRANCH="main"
@@ -37,22 +38,19 @@ 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
echo "Triggering pipeline for $REPO on branch $BRANCH..."
response=$(curl -sk -w "\n%{http_code}" -X POST \
-H "Authorization: Bearer $WOODPECKER_TOKEN" \
-H "Content-Type: application/json" \
-d "$(jq -n --arg b "$BRANCH" '{branch: $b}')" \
"${WOODPECKER_URL}/api/repos/${REPO}/pipelines")
"${WOODPECKER_URL}/api/repos/${REPO_ID}/pipelines")
http_code=$(echo "$response" | tail -n1)
body=$(echo "$response" | sed '$d')