import paramiko ssh = paramiko.SSHClient() ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy()) ssh.connect('140.44.4.41', username='root', key_filename=r'C:\Users\Snarf\.ssh\id_ed25519_snarfnet', timeout=10) with open('snarfcode_update.bundle', 'rb') as f: bundle_data = f.read() stdin, stdout, stderr = ssh.exec_command('cat > /tmp/snarfcode_update.bundle') stdin.write(bundle_data) stdin.close() stdout.read() print("Bundle piped to /tmp/snarfcode_update.bundle on 140.44.4.41") cmds = [ "RUNNING_POD=$(kubectl get pod -n infrastructure -l app=gitea --field-selector status.phase=Running -o jsonpath='{.items[0].metadata.name}') && kubectl cp /tmp/snarfcode_update.bundle infrastructure/${RUNNING_POD}:/tmp/snarfcode_update.bundle -c gitea", "kubectl exec -n infrastructure deployment/gitea -c gitea -- sh -c 'cd /data/git/gitea-repositories/snarf/snarfcode.git && git fetch /tmp/snarfcode_update.bundle HEAD:alpha && git update-ref refs/heads/alpha FETCH_HEAD && git update-ref refs/heads/main FETCH_HEAD && git log -n 3 --oneline refs/heads/alpha'", "rm -f /tmp/snarfcode_update.bundle" ] for cmd in cmds: print(f">>> {cmd}") stdin, stdout, stderr = ssh.exec_command(cmd) print(stdout.read().decode()) err = stderr.read().decode() if err: print("STDERR:", err) ssh.close()