Commit 6f53f73 1 parent e00b392 commit 6f53f73 Copy full SHA for 6f53f73
File tree 1 file changed +15
-5
lines changed
1 file changed +15
-5
lines changed Original file line number Diff line number Diff line change @@ -30,16 +30,26 @@ jobs:
30
30
run : |
31
31
KV_NAMESPACE="SUBLINK_KV"
32
32
echo "Checking for KV namespace: $KV_NAMESPACE"
33
- LIST_OUTPUT=$(wrangler kv namespace list)
34
- echo "KV namespace list output: $LIST_OUTPUT"
33
+ if ! LIST_OUTPUT=$(wrangler kv namespace list 2>&1); then
34
+ echo "Error getting KV namespace list: $LIST_OUTPUT"
35
+ exit 1
36
+ fi
37
+
38
+ LIST_OUTPUT=$(echo "$LIST_OUTPUT" | grep -v "Cloudflare collects" | grep -v "telemetry")
39
+ echo "Cleaned KV namespace list output: $LIST_OUTPUT"
40
+
41
+ if ! echo "$LIST_OUTPUT" | jq empty; then
42
+ echo "Invalid JSON output from wrangler"
43
+ exit 1
44
+ fi
35
45
36
46
KV_ID=$(echo "$LIST_OUTPUT" | jq -r '.[] | select(.title == "sublink-worker-'$KV_NAMESPACE'") | .id')
37
47
38
48
if [ -z "$KV_ID" ]; then
39
49
echo "KV namespace $KV_NAMESPACE does not exist. Creating..."
40
- CREATE_OUTPUT=$(wrangler kv namespace create "$KV_NAMESPACE")
50
+ CREATE_OUTPUT=$(wrangler kv namespace create "$KV_NAMESPACE" 2>&1 )
41
51
echo "Create KV namespace output: $CREATE_OUTPUT"
42
- KV_ID=$(echo "$CREATE_OUTPUT" | grep -oP 'id = "\K[^"]+ ')
52
+ KV_ID=$(echo "$CREATE_OUTPUT" | grep -o '[0-9a-f]\{32\} ')
43
53
44
54
if [ -z "$KV_ID" ]; then
45
55
echo "Failed to extract KV ID. Full output: $CREATE_OUTPUT"
48
58
49
59
echo "KV namespace $KV_NAMESPACE created successfully with ID: $KV_ID"
50
60
else
51
- echo "KV namespace $KV_NAMESPACE already exists with ID: $KV_ID"
61
+ echo "KV namespace $KV_NAMESPACE already exists with ID: $KV_ID"
52
62
fi
53
63
echo "KV_ID=$KV_ID" >> $GITHUB_ENV
54
64
You can’t perform that action at this time.
0 commit comments