-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdeploy.sh
More file actions
executable file
·61 lines (51 loc) · 1.72 KB
/
deploy.sh
File metadata and controls
executable file
·61 lines (51 loc) · 1.72 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#!/usr/bin/env bash
# Deploy SignThat to IPFS via Pinata.
# Reads JWT from openclaw secrets or PINATA_JWT env var.
set -euo pipefail
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
HTML="$SCRIPT_DIR/dist/signthat.html"
SDK_PY="$SCRIPT_DIR/sdk/python/signthat.py"
SDK_TS="$SCRIPT_DIR/sdk/typescript/src/index.ts"
SECRETS_FILE="$HOME/.openclaw/workspace/.secrets/pinata.json"
# Build first
echo "Building..."
bash "$SCRIPT_DIR/build.sh"
echo
# Get JWT
if [ -z "${PINATA_JWT:-}" ]; then
if [ -f "$SECRETS_FILE" ]; then
PINATA_JWT=$(python3 -c "import json; print(json.load(open('$SECRETS_FILE'))['jwt'])")
else
echo "Error: Set PINATA_JWT or create $SECRETS_FILE"
exit 1
fi
fi
# Pin to IPFS
echo "Pinning to IPFS..."
RESPONSE=$(curl -s -X POST "https://api.pinata.cloud/pinning/pinFileToIPFS" \
-H "Authorization: Bearer $PINATA_JWT" \
-F "file=@${HTML};filename=index.html" \
-F 'pinataOptions={"cidVersion":1}' \
-F 'pinataMetadata={"name":"signthat"}')
CID=$(echo "$RESPONSE" | python3 -c "import sys,json; print(json.load(sys.stdin)['IpfsHash'])")
if [ -z "$CID" ]; then
echo "Error: Failed to pin. Response: $RESPONSE"
exit 1
fi
GATEWAY_URL="https://dweb.link/ipfs/$CID"
echo "Pinned: $CID"
echo "URL: $GATEWAY_URL"
echo
# Update SDKs with new CID
sed -i "s|DEFAULT_BASE_URL = \".*\"|DEFAULT_BASE_URL = \"$GATEWAY_URL\"|" "$SDK_PY"
echo "Updated SDK base URL in $SDK_PY"
if [ -f "$SDK_TS" ]; then
sed -i "s|\"https://dweb.link/ipfs/[^\"]*\"|\"$GATEWAY_URL\"|" "$SDK_TS"
echo "Updated SDK base URL in $SDK_TS"
fi
echo
echo "Gateway URLs:"
echo " dweb: https://dweb.link/ipfs/$CID"
echo " ipfs.io: https://ipfs.io/ipfs/$CID"
echo
echo "Done. Test: ${GATEWAY_URL}#712/eyJ..."