您不能選擇超過 %s 個話題 話題必須以字母或數字為開頭,可包含連接號 ('-') 且最長為 35 個字
此存儲庫已封存,您能瀏覽檔案及複製此存儲庫,但不能推送、建立問題及拉取請求。
 
 
 
 
 
 

38 行
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()