欸?
This commit is contained in:
parent
a8d23feddd
commit
6962063c69
15
deploy.py
15
deploy.py
@ -5,6 +5,11 @@ from pathlib import Path
|
|||||||
|
|
||||||
ON_CF = os.getenv("CF_PAGES") == "1"
|
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]:
|
def get_env_info() -> dict[str, str]:
|
||||||
# 读取环境变量
|
# 读取环境变量
|
||||||
@ -23,10 +28,10 @@ def get_env_info() -> dict[str, str]:
|
|||||||
env_info["branch"] = branch.strip()
|
env_info["branch"] = branch.strip()
|
||||||
# git commit hash
|
# git commit hash
|
||||||
# on cf -> get from CF_PAGES_COMMIT_SHA
|
# on cf -> get from CF_PAGES_COMMIT_SHA
|
||||||
if ON_CF:
|
# if ON_CF:
|
||||||
commit = os.getenv("CF_PAGES_COMMIT_SHA") or "unknown"
|
# commit = os.getenv("CF_PAGES_COMMIT_SHA") or "unknown"
|
||||||
else:
|
# else:
|
||||||
commit = run(
|
commit = run(
|
||||||
["git", "rev-parse", "HEAD"],
|
["git", "rev-parse", "HEAD"],
|
||||||
capture_output=True,
|
capture_output=True,
|
||||||
text=True,
|
text=True,
|
||||||
@ -43,7 +48,7 @@ def get_env_info() -> dict[str, str]:
|
|||||||
env_info["message"] = message.stdout.strip()
|
env_info["message"] = message.stdout.strip()
|
||||||
# git tag
|
# git tag
|
||||||
if ON_CF:
|
if ON_CF:
|
||||||
tag = os.getenv("CF_PAGES_COMMIT_TAG") or "cf_deploy"
|
tag = os.getenv("CF_PAGES_COMMIT_SHA") or "cf_deploy"
|
||||||
else:
|
else:
|
||||||
tag = run(
|
tag = run(
|
||||||
["git", "describe", "--tags"], capture_output=True, text=True, encoding="utf-8"
|
["git", "describe", "--tags"], capture_output=True, text=True, encoding="utf-8"
|
||||||
|
Loading…
Reference in New Issue
Block a user