fix: improve Portainer deployment script with enhanced logging and error handling
Some checks failed
Build And Publish Production Image / Build And Publish Production Image (push) Failing after 11s
Some checks failed
Build And Publish Production Image / Build And Publish Production Image (push) Failing after 11s
This commit is contained in:
@@ -42,11 +42,18 @@ jobs:
|
||||
PORTAINER_ENDPOINT_ID: ${{ secrets.PORTAINER_ENDPOINT_ID }}
|
||||
run: |
|
||||
set -u
|
||||
set +e
|
||||
|
||||
PORTAINER_BASE_URL=$(printf '%s' "${PORTAINER_URL}" | sed -E 's/[[:space:]]+$//; s#/*$##')
|
||||
|
||||
echo "Portainer deploy debug"
|
||||
echo "PORTAINER_URL=${PORTAINER_URL}"
|
||||
echo "PORTAINER_BASE_URL=${PORTAINER_BASE_URL}"
|
||||
echo "STACK_NAME=${STACK_NAME}"
|
||||
echo "PORTAINER_ENDPOINT_ID=${PORTAINER_ENDPOINT_ID}"
|
||||
echo "HTTP_PROXY=${HTTP_PROXY:-<empty>}"
|
||||
echo "HTTPS_PROXY=${HTTPS_PROXY:-<empty>}"
|
||||
echo "NO_PROXY=${NO_PROXY:-<empty>}"
|
||||
|
||||
echo "Current runner network info:"
|
||||
if command -v ip >/dev/null 2>&1; then
|
||||
@@ -56,7 +63,7 @@ jobs:
|
||||
hostname -I || true
|
||||
fi
|
||||
|
||||
PORTAINER_HOST=$(printf '%s' "${PORTAINER_URL}" | sed -E 's#^[a-zA-Z]+://##; s#/.*$##; s/:.*$//')
|
||||
PORTAINER_HOST=$(printf '%s' "${PORTAINER_BASE_URL}" | sed -E 's#^[a-zA-Z]+://##; s#/.*$##; s/:.*$//')
|
||||
echo "Resolved host target: ${PORTAINER_HOST}"
|
||||
|
||||
if command -v getent >/dev/null 2>&1; then
|
||||
@@ -68,9 +75,10 @@ jobs:
|
||||
STACKS_ERR=$(mktemp)
|
||||
|
||||
STACKS_HTTP_CODE=$(curl -sS \
|
||||
--noproxy "*" \
|
||||
-o "${STACKS_BODY}" \
|
||||
-w "%{http_code}" \
|
||||
"${PORTAINER_URL}/api/stacks" \
|
||||
"${PORTAINER_BASE_URL}/api/stacks" \
|
||||
-H "X-API-Key: ${PORTAINER_API_KEY}" \
|
||||
2>"${STACKS_ERR}")
|
||||
STACKS_CURL_EXIT=$?
|
||||
@@ -105,9 +113,10 @@ jobs:
|
||||
'{StackFileContent: $stack_file, Env: [], Prune: false, PullImage: false}')
|
||||
|
||||
APPLY_HTTP_CODE=$(curl -sS -X PUT \
|
||||
--noproxy "*" \
|
||||
-o "${APPLY_BODY}" \
|
||||
-w "%{http_code}" \
|
||||
"${PORTAINER_URL}/api/stacks/${STACK_ID}?endpointId=${PORTAINER_ENDPOINT_ID}" \
|
||||
"${PORTAINER_BASE_URL}/api/stacks/${STACK_ID}?endpointId=${PORTAINER_ENDPOINT_ID}" \
|
||||
-H "X-API-Key: ${PORTAINER_API_KEY}" \
|
||||
-H "Content-Type: application/json" \
|
||||
-d "${PAYLOAD}" \
|
||||
@@ -122,9 +131,10 @@ jobs:
|
||||
'{Name: $name, StackFileContent: $stack_file, Env: [], FromAppTemplate: false}')
|
||||
|
||||
APPLY_HTTP_CODE=$(curl -sS -X POST \
|
||||
--noproxy "*" \
|
||||
-o "${APPLY_BODY}" \
|
||||
-w "%{http_code}" \
|
||||
"${PORTAINER_URL}/api/stacks/create/standalone/string?endpointId=${PORTAINER_ENDPOINT_ID}" \
|
||||
"${PORTAINER_BASE_URL}/api/stacks/create/standalone/string?endpointId=${PORTAINER_ENDPOINT_ID}" \
|
||||
-H "X-API-Key: ${PORTAINER_API_KEY}" \
|
||||
-H "Content-Type: application/json" \
|
||||
-d "${PAYLOAD}" \
|
||||
|
||||
Reference in New Issue
Block a user