fix(ci): Escape dollar signs for shell variables in Woodpecker
Some checks failed
ci/woodpecker/push/woodpecker Pipeline failed

Woodpecker interprets $ as variable substitution in YAML, so we need to
use $$ to escape it and pass a literal $ to the shell script.

Changed from a for loop to explicit function calls with escaped variables:
- Use $$ instead of $ for all shell variables
- Function-based approach for cleaner variable passing
- Each package explicitly called: link_package "stack-api" etc.

This fixes the variable expansion issue where ${package} was empty,
resulting in URLs like "container//-/link/stack" (double slash).

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-02-08 14:58:15 -06:00
parent aad6cb75d0
commit f1e6fc29f6

View File

@@ -278,18 +278,24 @@ steps:
commands:
- apk add --no-cache curl
- |
for package in stack-api stack-web stack-postgres stack-openbao stack-orchestrator; do
STATUS=$(curl -s -o /dev/null -w "%{http_code}" -X POST \
-H "Authorization: token $GITEA_TOKEN" \
"https://git.mosaicstack.dev/api/v1/packages/mosaic/container/${package}/-/link/stack")
if [ "$STATUS" = "201" ] || [ "$STATUS" = "204" ]; then
echo "✅ Linked ${package} to stack"
elif [ "$STATUS" = "400" ]; then
echo "✅ ${package} already linked (OK)"
link_package() {
PKG="$$1"
STATUS=$$(curl -s -o /dev/null -w "%{http_code}" -X POST \
-H "Authorization: token $$GITEA_TOKEN" \
"https://git.mosaicstack.dev/api/v1/packages/mosaic/container/$$PKG/-/link/stack")
if [ "$$STATUS" = "201" ] || [ "$$STATUS" = "204" ]; then
echo "✅ Linked $$PKG to stack"
elif [ "$$STATUS" = "400" ]; then
echo "✅ $$PKG already linked (OK)"
else
echo "❌ Warning: ${package} link returned $STATUS"
echo "❌ $$PKG link failed with status $$STATUS"
fi
done
}
link_package "stack-api"
link_package "stack-web"
link_package "stack-postgres"
link_package "stack-openbao"
link_package "stack-orchestrator"
when:
- branch: [main, develop]
event: [push, manual, tag]