fix: deploy to portainer
This commit is contained in:
parent
1765fca240
commit
d24242f359
|
|
@ -104,10 +104,22 @@ deploy-to-portainer:
|
||||||
--arg content "$STACK_FILE_CONTENT" \
|
--arg content "$STACK_FILE_CONTENT" \
|
||||||
'{name: $name, stackFileContent: $content, prune: true}')
|
'{name: $name, stackFileContent: $content, prune: true}')
|
||||||
|
|
||||||
curl -s -X POST "$PORTAINER_URL/api/stacks?type=2&method=string&endpointId=$PORTAINER_ENDPOINT_ID" \
|
CREATE_RESP=$(curl -s -w "HTTPSTATUS:%{http_code}" \
|
||||||
|
-X POST "$PORTAINER_URL/api/stacks?type=2&method=string&endpointId=$PORTAINER_ENDPOINT_ID" \
|
||||||
-H "X-API-Key: $PORTAINER_API_KEY" \
|
-H "X-API-Key: $PORTAINER_API_KEY" \
|
||||||
-H "Content-Type: application/json" \
|
-H "Content-Type: application/json" \
|
||||||
--data "$JSON_PAYLOAD"
|
--data "$JSON_PAYLOAD")
|
||||||
|
|
||||||
|
CREATE_BODY=$(echo "$CREATE_RESP" | sed -e 's/HTTPSTATUS:.*//g')
|
||||||
|
CREATE_STATUS=$(echo "$CREATE_RESP" | tr -d '\n' | sed -e 's/.*HTTPSTATUS://')
|
||||||
|
|
||||||
|
echo "➡️ Create status: $CREATE_STATUS"
|
||||||
|
echo "➡️ Create body: $CREATE_BODY"
|
||||||
|
|
||||||
|
if [ "$CREATE_STATUS" != "200" ] && [ "$CREATE_STATUS" != "201" ]; then
|
||||||
|
echo "❌ Erreur lors de la création de la stack (HTTP $CREATE_STATUS)"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
echo "✅ Stack créée."
|
echo "✅ Stack créée."
|
||||||
else
|
else
|
||||||
|
|
@ -118,10 +130,22 @@ deploy-to-portainer:
|
||||||
--arg content "$STACK_FILE_CONTENT" \
|
--arg content "$STACK_FILE_CONTENT" \
|
||||||
'{id: ($id|tonumber), stackFileContent: $content, prune: true}')
|
'{id: ($id|tonumber), stackFileContent: $content, prune: true}')
|
||||||
|
|
||||||
curl -s -X PUT "$PORTAINER_URL/api/stacks/$STACK_ID?endpointId=$PORTAINER_ENDPOINT_ID" \
|
UPDATE_RESP=$(curl -s -w "HTTPSTATUS:%{http_code}" \
|
||||||
|
-X PUT "$PORTAINER_URL/api/stacks/$STACK_ID?endpointId=$PORTAINER_ENDPOINT_ID" \
|
||||||
-H "X-API-Key: $PORTAINER_API_KEY" \
|
-H "X-API-Key: $PORTAINER_API_KEY" \
|
||||||
-H "Content-Type: application/json" \
|
-H "Content-Type: application/json" \
|
||||||
--data "$JSON_PAYLOAD"
|
--data "$JSON_PAYLOAD")
|
||||||
|
|
||||||
|
UPDATE_BODY=$(echo "$UPDATE_RESP" | sed -e 's/HTTPSTATUS:.*//g')
|
||||||
|
UPDATE_STATUS=$(echo "$UPDATE_RESP" | tr -d '\n' | sed -e 's/.*HTTPSTATUS://')
|
||||||
|
|
||||||
|
echo "➡️ Update status: $UPDATE_STATUS"
|
||||||
|
echo "➡️ Update body: $UPDATE_BODY"
|
||||||
|
|
||||||
|
if [ "$UPDATE_STATUS" != "200" ]; then
|
||||||
|
echo "❌ Erreur lors de la mise à jour de la stack (HTTP $UPDATE_STATUS)"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
echo "✅ Stack mise à jour."
|
echo "✅ Stack mise à jour."
|
||||||
fi
|
fi
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue