-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdeploy.sh
79 lines (54 loc) · 1.86 KB
/
deploy.sh
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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
#!/bin/bash
# Load variables from .env file
source .env
# Parse JSON using jq tool
json=$(cat approvedApps.json)
length=$(echo ${json} | jq '. | length')
# Check if RPC_URL environment variable exists
if [ -z "${RPC_URL}" ]; then
# If not, set it
RPC_URL="https://api.cartridge.gg/x/${WORLD_NAME}/katana"
fi
if [ ! -d "dist" ]; then
# If not, create it
mkdir dist
fi
# make directory dist if it does not exist and all apps cloned there should be inside that directory
cd dist
rm -r ./*
dist_dir=$(pwd)
echo "----------------------------------------------------------------------------"
echo "Deploying ${length} apps"
for (( i=0; i<${length}; i++ ))
do
app=$(echo ${json} | jq -r ".[${i}]")
name=$(echo ${app} | jq -r ".name")
git_repo=$(echo ${app} | jq -r '."git-repository"')
contracts_dir=$(echo ${app} | jq -r '."contracts-directory"')
scripts=$(echo ${app} | jq -r ".scripts[]")
echo "----------------------------------------------------------------------------"
echo "[${i}] App: ${name}"
echo "Cloning repository (${git_repo}) to ${i}"
git clone ${git_repo} ${i}
rm -rf ${i}/.git
cd ${i}/${contracts_dir}
echo "Building contract"
sozo build
sed -i 's#rpc_url = ".*"#rpc_url = "'"$RPC_URL"'"#' Scarb.toml
sed -i 's/account_address = ".*"/account_address = "'"$ACCOUNT_ADDRESS"'"/' Scarb.toml
sed -i 's/private_key = ".*"/private_key = "'"$PRIVATE_KEY"'"/' Scarb.toml
echo "Deploying the contract"
sozo migrate --name $WORLD_NAME
scarb run initialize
scarb run upload_manifest $MANIFEST_URL
for script in ${scripts}
do
echo "scarb run ${script}"
scarb run ${script}
sleep 10
done
cd $dist_dir
done
echo "----------------------------------------------------------------------------"
echo "Completed deployment successfully"
echo "----------------------------------------------------------------------------"