-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdeploy.py
More file actions
37 lines (28 loc) · 749 Bytes
/
deploy.py
File metadata and controls
37 lines (28 loc) · 749 Bytes
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
#!/usr/bin/python3
import subprocess as sb
import os
import shutil
import json
print("Deploy")
print("=> Copying wrangler.toml")
shutil.copy("wrangler.toml.example", "wrangler.toml")
print("=> Creating KV...")
print("return", os.system("npx wrangler kv:namespace create db"))
print("=> Get KV id...")
kv_id = ""
data = json.loads(sb.getoutput("npx wrangler kv:namespace list"))
for i in data:
if "secure-pastebin-db" in i["title"]:
kv_id = i["id"]
print("KV", i["title"], "OK")
else:
print("KV", i["title"])
f = open("wrangler.toml", "r")
content = f.read()
f.close()
print("=> Replacing...")
content = content.replace("KVID", kv_id)
f = open("wrangler.toml", "w")
f.write(content)
f.close()
print("=> Done")