From 6962063c69669741aa26de998fc50f2b74c1c910 Mon Sep 17 00:00:00 2001 From: shenjack <3695888@qq.com> Date: Sat, 20 Apr 2024 22:37:30 +0800 Subject: [PATCH] =?UTF-8?q?=E6=AC=B8=EF=BC=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- deploy.py | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/deploy.py b/deploy.py index 2dbcee2..820119a 100644 --- a/deploy.py +++ b/deploy.py @@ -5,6 +5,11 @@ from pathlib import Path ON_CF = os.getenv("CF_PAGES") == "1" +if ON_CF: + print("Running on Cloudflare Pages, trying to git fetch --all") + run(["git", "fetch", "--all"], check=False) + + def get_env_info() -> dict[str, str]: # 读取环境变量 @@ -23,10 +28,10 @@ def get_env_info() -> dict[str, str]: env_info["branch"] = branch.strip() # git commit hash # on cf -> get from CF_PAGES_COMMIT_SHA - if ON_CF: - commit = os.getenv("CF_PAGES_COMMIT_SHA") or "unknown" - else: - commit = run( + # if ON_CF: + # commit = os.getenv("CF_PAGES_COMMIT_SHA") or "unknown" + # else: + commit = run( ["git", "rev-parse", "HEAD"], capture_output=True, text=True, @@ -43,7 +48,7 @@ def get_env_info() -> dict[str, str]: env_info["message"] = message.stdout.strip() # git tag if ON_CF: - tag = os.getenv("CF_PAGES_COMMIT_TAG") or "cf_deploy" + tag = os.getenv("CF_PAGES_COMMIT_SHA") or "cf_deploy" else: tag = run( ["git", "describe", "--tags"], capture_output=True, text=True, encoding="utf-8"