再妥协一下
This commit is contained in:
parent
df15584b62
commit
a661d55d1f
45
deploy.py
45
deploy.py
@ -8,28 +8,38 @@ ON_CF = os.getenv("CF_PAGES") == "1"
|
|||||||
|
|
||||||
if ON_CF:
|
if ON_CF:
|
||||||
print("Running on Cloudflare Pages, trying to git fetch --all")
|
print("Running on Cloudflare Pages, trying to git fetch --all")
|
||||||
|
# add remote
|
||||||
|
run(
|
||||||
|
["git", "remote", "add", "origin", "https://github.com/shenjackyuanjie/fast-namerena.git"],
|
||||||
|
)
|
||||||
result = run(["git", "fetch", "--all"], check=False)
|
result = run(["git", "fetch", "--all"], check=False)
|
||||||
print(f"git fetch --all: {result.stdout}")
|
print(f"git fetch --all: {result}")
|
||||||
|
|
||||||
|
|
||||||
def get_env_info() -> dict[str, str]:
|
def get_env_info() -> dict[str, str]:
|
||||||
# 读取环境变量
|
# 读取环境变量
|
||||||
env_info = {}
|
env_info = {}
|
||||||
# git branch
|
# git branch
|
||||||
branch = run(
|
if ON_CF:
|
||||||
["git", "branch", "--show-current"],
|
branch = os.getenv("CF_PAGES_BRANCH") or "unknown"
|
||||||
capture_output=True,
|
else:
|
||||||
text=True,
|
branch = run(
|
||||||
encoding="utf-8",
|
["git", "branch", "--show-current"],
|
||||||
).stdout
|
capture_output=True,
|
||||||
|
text=True,
|
||||||
|
encoding="utf-8",
|
||||||
|
).stdout
|
||||||
env_info["branch"] = branch.strip()
|
env_info["branch"] = branch.strip()
|
||||||
# git commit hash
|
# git commit hash
|
||||||
commit = run(
|
if ON_CF:
|
||||||
["git", "rev-parse", "HEAD"],
|
commit = os.getenv("CF_PAGES_COMMIT_SHA") or "unknown"
|
||||||
capture_output=True,
|
else:
|
||||||
text=True,
|
commit = run(
|
||||||
encoding="utf-8",
|
["git", "rev-parse", "HEAD"],
|
||||||
).stdout
|
capture_output=True,
|
||||||
|
text=True,
|
||||||
|
encoding="utf-8",
|
||||||
|
).stdout
|
||||||
env_info["commit"] = commit.strip()
|
env_info["commit"] = commit.strip()
|
||||||
# git commit message
|
# git commit message
|
||||||
message = run(
|
message = run(
|
||||||
@ -40,9 +50,12 @@ def get_env_info() -> dict[str, str]:
|
|||||||
)
|
)
|
||||||
env_info["message"] = message.stdout.strip()
|
env_info["message"] = message.stdout.strip()
|
||||||
# git tag
|
# git tag
|
||||||
tag = run(
|
if ON_CF:
|
||||||
["git", "describe", "--tags"], capture_output=True, text=True, encoding="utf-8"
|
tag = "cf_pages"
|
||||||
).stdout
|
else:
|
||||||
|
tag = run(
|
||||||
|
["git", "describe", "--tags"], capture_output=True, text=True, encoding="utf-8"
|
||||||
|
).stdout
|
||||||
env_info["tag"] = tag.strip()
|
env_info["tag"] = tag.strip()
|
||||||
return env_info
|
return env_info
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user