Skip to content

Commit d913f57

Browse files
committed
update parsing
1 parent c3e11a8 commit d913f57

File tree

1 file changed

+22
-1
lines changed

1 file changed

+22
-1
lines changed

.github/workflows/trigger-n8n-workflow.yml

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -481,7 +481,28 @@ jobs:
481481
PY
482482
)"
483483
if [[ -n "$HEADER_SIG" ]]; then
484-
EXPECTED_SIG="sha256=$(printf '%s' "$HTTP_BODY" | openssl dgst -binary -sha256 -hmac "$N8N_RECEIVING_TOKEN" | base64 | tr -d '\n')"
484+
PAYLOAD_FOR_SIG="$(
485+
HTTP_BODY_VAR="$HTTP_BODY" python3 - <<'PY'
486+
import json
487+
import os
488+
489+
body = os.environ.get("HTTP_BODY_VAR", "")
490+
try:
491+
data = json.loads(body)
492+
except json.JSONDecodeError:
493+
data = None
494+
495+
payload = data.get("payload") if isinstance(data, dict) else None
496+
if payload is None:
497+
raise SystemExit(0)
498+
499+
print(json.dumps(payload, separators=(",", ":")), end="")
500+
PY
501+
)"
502+
if [[ -z "$PAYLOAD_FOR_SIG" ]]; then
503+
PAYLOAD_FOR_SIG="$HTTP_BODY"
504+
fi
505+
EXPECTED_SIG="sha256=$(printf '%s' "$PAYLOAD_FOR_SIG" | openssl dgst -binary -sha256 -hmac "$N8N_RECEIVING_TOKEN" | base64 | tr -d '\n')"
485506
if [[ "$HEADER_SIG" != "$EXPECTED_SIG" ]]; then
486507
echo "Response signature mismatch."
487508
echo "error=true" >> "$GITHUB_OUTPUT"

0 commit comments

Comments
 (0)