diff options
author | xengineering <me@xengineering.eu> | 2025-04-11 17:22:48 +0200 |
---|---|---|
committer | xengineering <me@xengineering.eu> | 2025-04-11 17:41:29 +0200 |
commit | 617178f01c1b1acbd2e0f3e66a66f2a5f375e3c8 (patch) | |
tree | d68ea539b747efd4e09d3b4e168ecf84e4e425c7 | |
parent | 29dfea5e6def230b677116f175f6e67d968b92a9 (diff) | |
download | iot-contact-617178f01c1b1acbd2e0f3e66a66f2a5f375e3c8.tar iot-contact-617178f01c1b1acbd2e0f3e66a66f2a5f375e3c8.tar.zst iot-contact-617178f01c1b1acbd2e0f3e66a66f2a5f375e3c8.zip |
tools: Add deploy.py
This makes it easier to deploy the installed artifacts to a remote
server as part of the deployment.
-rwxr-xr-x | tools/deploy.py | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/tools/deploy.py b/tools/deploy.py new file mode 100755 index 0000000..62a4ed6 --- /dev/null +++ b/tools/deploy.py @@ -0,0 +1,43 @@ +#!/usr/bin/env python3 + + +import argparse +import subprocess +import pathlib + + +def main() -> None: + parser = argparse.ArgumentParser( + description="Use OpenSSH and rsync to deploy artifacts", + ) + + parser.add_argument( + "-a", "--artifacts", required=True, help="local path to artifacts folder" + ) + parser.add_argument( + "-H", "--host", default="cloud", help="target `Host` name from ~/.ssh/config" + ) + parser.add_argument( + "-p", + "--path", + default="/srv/http/deploy.xengineering.eu/public/git/iot-contact/main/", + help="remote path to destination folder on server", + ) + + args = parser.parse_args() + + subprocess.run( + [ + "rsync", + "-av", + "--delete", + f"{str(pathlib.Path(args.artifacts))}/", + f"{args.host}:{args.path}", + ], + shell=False, + check=True, + ) + + +if __name__ == "__main__": + main() |