fix: Use POST for Gitea package link API and handle already-linked
Some checks failed
ci/woodpecker/push/woodpecker Pipeline failed
Some checks failed
ci/woodpecker/push/woodpecker Pipeline failed
The link endpoint uses POST (not PUT) and returns 400 when already linked. Handle both 204 (linked) and 400 (already linked) as success. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -271,20 +271,24 @@ steps:
|
|||||||
# Links all Docker packages to the mosaic/stack repository
|
# Links all Docker packages to the mosaic/stack repository
|
||||||
# This makes packages visible on the repository page in Gitea
|
# This makes packages visible on the repository page in Gitea
|
||||||
link-packages:
|
link-packages:
|
||||||
image: alpine:latest
|
image: alpine:3
|
||||||
environment:
|
environment:
|
||||||
GITEA_TOKEN:
|
GITEA_TOKEN:
|
||||||
from_secret: gitea_token
|
from_secret: gitea_token
|
||||||
commands:
|
commands:
|
||||||
- apk add --no-cache curl
|
- apk add --no-cache curl
|
||||||
- |
|
- |
|
||||||
# Link all container packages to the repository
|
|
||||||
for package in api web postgres openbao orchestrator; do
|
for package in api web postgres openbao orchestrator; do
|
||||||
echo "Linking package mosaic/${package} to repository stack..."
|
STATUS=$(curl -s -o /dev/null -w "%{http_code}" -X POST \
|
||||||
curl -X PUT \
|
|
||||||
-H "Authorization: token $GITEA_TOKEN" \
|
-H "Authorization: token $GITEA_TOKEN" \
|
||||||
-H "Content-Type: application/json" \
|
"https://git.mosaicstack.dev/api/v1/packages/mosaic/container/${package}/-/link/stack")
|
||||||
"https://git.mosaicstack.dev/api/v1/packages/mosaic/container/${package}/-/link/stack" || echo "Failed to link ${package} (may not exist yet)"
|
if [ "$STATUS" = "204" ]; then
|
||||||
|
echo "Linked ${package} to stack"
|
||||||
|
elif [ "$STATUS" = "400" ]; then
|
||||||
|
echo "${package} already linked (OK)"
|
||||||
|
else
|
||||||
|
echo "Warning: ${package} link returned $STATUS"
|
||||||
|
fi
|
||||||
done
|
done
|
||||||
when:
|
when:
|
||||||
- branch: [main, develop]
|
- branch: [main, develop]
|
||||||
|
|||||||
Reference in New Issue
Block a user