-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathpushUpdate.py
More file actions
33 lines (26 loc) · 889 Bytes
/
pushUpdate.py
File metadata and controls
33 lines (26 loc) · 889 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
import subprocess
import os
PRIVATE_KEY = "sfsugamedev_key"
IP_ADDRESS = "64.227.109.110"
BUILD_PATH = "build/*"
REMOTE_PATH = "/var/www/react-app"
def run_command(command):
try:
print(f"Running: {command}")
subprocess.run(command, check=True, shell=True)
except subprocess.CalledProcessError as e:
print(f"Error: {e}")
exit(1)
def deploy():
scp_command = f"scp -i {PRIVATE_KEY} -r {BUILD_PATH} root@{IP_ADDRESS}:{REMOTE_PATH}"
run_command(scp_command)
ssh_commands = [
f"sudo chown -R www-data:www-data {REMOTE_PATH}",
f"sudo chmod -R 755 {REMOTE_PATH}",
"sudo systemctl restart nginx"
]
ssh_command = f'ssh -i {PRIVATE_KEY} root@{IP_ADDRESS} "' + ' && '.join(ssh_commands) + '"'
run_command(ssh_command)
print("Deployment completed successfully!")
if __name__ == "__main__":
deploy()