You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
This repo is archived. You can view files and clone it, but cannot push or open issues/pull-requests.
 
 
 
 
 
 

38 lines
745 B

  1. import argparse
  2. import subprocess
  3. import sys
  4. def build():
  5. process = subprocess.run(["hugo"])
  6. if process.returncode != 0:
  7. sys.exit("build failed")
  8. def deploy(*, dry_run):
  9. cmd = [
  10. "rsync",
  11. "--itemize-changes",
  12. "--recursive",
  13. "--delete",
  14. "public/",
  15. "dedi3:/srv/nginx/html/books/python/",
  16. ]
  17. if dry_run:
  18. cmd += ["--dry-run"]
  19. process = subprocess.run(cmd)
  20. if process.returncode != 0:
  21. sys.exit("deployment failed")
  22. def main():
  23. parser = argparse.ArgumentParser()
  24. parser.add_argument("-n", "--dry-run", action="store_true")
  25. args = parser.parse_args()
  26. build()
  27. deploy(dry_run=args.dry_run)
  28. if __name__ == "__main__":
  29. main()