forked from PCJones/Ultimate-Splinterlands-Bot-V2
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdeploy_bot.py
More file actions
65 lines (58 loc) · 2.22 KB
/
deploy_bot.py
File metadata and controls
65 lines (58 loc) · 2.22 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
62
63
64
65
import subprocess
import os
import platform
# Your account details
ACCOUNT_NAME = "acolyte_20684"
# Step 1: Clone the repository
def clone_repo():
try:
print("Cloning the repository...")
subprocess.check_call(["git", "clone", "https://github.com/spork2106/Ultimate-Splinterlands-Bot-V2.git"])
except subprocess.CalledProcessError:
print("Error cloning the repository. Please check if Git is installed.")
# Step 2: Install .NET Core if not installed
def install_dotnet():
try:
print("Checking .NET installation...")
subprocess.check_call(["dotnet", "--version"])
print(".NET is already installed.")
except subprocess.CalledProcessError:
print(".NET not found. Installing...")
if platform.system() == "Windows":
subprocess.check_call(["dotnet-sdk", "--install"])
elif platform.system() == "Linux":
subprocess.check_call(["sudo", "apt", "install", "dotnet-sdk-6.0", "-y"])
# Step 3: Build the bot solution
def build_bot():
os.chdir("Ultimate-Splinterlands-Bot-V2")
print("Building the bot...")
try:
subprocess.check_call(["dotnet", "restore"])
subprocess.check_call(["dotnet", "build"])
print("Build completed successfully.")
except subprocess.CalledProcessError:
print("Build failed. Please check for errors.")
# Step 4: Deploy the bot
def deploy_bot():
print("Deploying the bot for account:", ACCOUNT_NAME)
try:
config_path = os.path.join("Config", "config.txt")
with open(config_path, "w") as config_file:
config_file.write(f"ACCOUNT_NAME={ACCOUNT_NAME}\n")
config_file.write("RANKED_FORMAT=wild\n")
config_file.write("START_BATTLE_ABOVE_ECR=50\n")
config_file.write("STOP_BATTLE_BELOW_ECR=1\n")
config_file.write("SHOW_SPS_REWARD=true\n")
config_file.write("THREADS=1\n")
print("Configuration file created.")
subprocess.check_call(["dotnet", "run"])
except Exception as e:
print(f"Error during deployment: {e}")
# Step 5: Main function to execute the steps
def main():
clone_repo()
install_dotnet()
build_bot()
deploy_bot()
if __name__ == "__main__":
main()