Compare commits
95 Commits
e5e8234fef
...
401dcddb10
Author | SHA1 | Date | |
---|---|---|---|
401dcddb10 | |||
517db988cf | |||
a7553bb958 | |||
82877e5872 | |||
11a6772862 | |||
06eaeed25a | |||
0cf493bcae | |||
bdb8e43448 | |||
508f485d8c | |||
2beffd3f80 | |||
98d37f01c6 | |||
aa64b4054f | |||
de340e5134 | |||
2afdabfd63 | |||
a661d55d1f | |||
df15584b62 | |||
71347c5484 | |||
6962063c69 | |||
a8d23feddd | |||
8ee43aef51 | |||
f94057cc3b | |||
7f96a37934 | |||
7394146e6a | |||
77f3e2b460 | |||
f19cda5a6a | |||
c1dcca7c95 | |||
4adb379180 | |||
cc3739f9d7 | |||
9fcf476bb3 | |||
d4bd75d041 | |||
3f6c715812 | |||
e4fc8bf46e | |||
d447f5c9db | |||
d8e9a2a766 | |||
fad98e0aff | |||
70800c71d3 | |||
3253d254f8 | |||
d459b058be | |||
d3737db200 | |||
afe86f5e73 | |||
5845d454ae | |||
d5fd66105f | |||
1e2d311ea9 | |||
47cfc77879 | |||
4cd9893a88 | |||
b0184dc072 | |||
1ab4565935 | |||
654839e7f0 | |||
fd8b430a7c | |||
aaf6f8a484 | |||
640801b6d9 | |||
735459c882 | |||
5959c6f9e4 | |||
03dd723851 | |||
e05b60656b | |||
f9f940230e | |||
db2aa5792b | |||
916053e870 | |||
b203b84f10 | |||
c2e290a1b1 | |||
f15e3440e1 | |||
b4c720fd9d | |||
16288fd3d2 | |||
940e478f37 | |||
8568bda570 | |||
e0fdfd87ff | |||
818de03445 | |||
25b4a0c07c | |||
72471a8d63 | |||
e20b856b17 | |||
a3f9d3c262 | |||
74c5961743 | |||
2d1853c8b0 | |||
5c96c353b5 | |||
8212bea543 | |||
d3b182886b | |||
a85eb5973e | |||
8e81a4d491 | |||
ee0b7fcf5b | |||
e5d92bcbc6 | |||
d978cbf546 | |||
59369560dd | |||
e1cf1969d7 | |||
a69c842cf2 | |||
f6898e5f05 | |||
1b4b54b88e | |||
a551f480d5 | |||
0c92c4d8cc | |||
b86642ed5d | |||
e66b627413 | |||
281489b92d | |||
e5079ce7ea | |||
99bc7c5b70 | |||
538986917b | |||
5e1c74f25d |
48
.github/workflows/static.yml
vendored
Normal file
48
.github/workflows/static.yml
vendored
Normal file
@ -0,0 +1,48 @@
|
|||||||
|
# Simple workflow for deploying static content to GitHub Pages
|
||||||
|
name: GitHub pages 部署
|
||||||
|
|
||||||
|
on:
|
||||||
|
# Runs on pushes targeting the default branch
|
||||||
|
push:
|
||||||
|
branches: ["main"]
|
||||||
|
|
||||||
|
# Allows you to run this workflow manually from the Actions tab
|
||||||
|
workflow_dispatch:
|
||||||
|
|
||||||
|
# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
|
||||||
|
permissions:
|
||||||
|
contents: read
|
||||||
|
pages: write
|
||||||
|
id-token: write
|
||||||
|
|
||||||
|
# Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued.
|
||||||
|
# However, do NOT cancel in-progress runs as we want to allow these production deployments to complete.
|
||||||
|
concurrency:
|
||||||
|
group: "pages"
|
||||||
|
cancel-in-progress: false
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
# Single deploy job since we're just deploying
|
||||||
|
deploy:
|
||||||
|
environment:
|
||||||
|
name: github-pages
|
||||||
|
url: ${{ steps.deployment.outputs.page_url }}
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: Checkout
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
with:
|
||||||
|
fetch-depth: 0
|
||||||
|
- name: 运行部署脚本
|
||||||
|
run: python3 deploy.py
|
||||||
|
|
||||||
|
- name: Setup Pages
|
||||||
|
uses: actions/configure-pages@v5
|
||||||
|
- name: Upload artifact
|
||||||
|
uses: actions/upload-pages-artifact@v3
|
||||||
|
with:
|
||||||
|
# Upload entire repository
|
||||||
|
path: '.'
|
||||||
|
- name: Deploy to GitHub Pages
|
||||||
|
id: deployment
|
||||||
|
uses: actions/deploy-pages@v4
|
@ -560,13 +560,23 @@
|
|||||||
0%,
|
0%,
|
||||||
80%,
|
80%,
|
||||||
100% {
|
100% {
|
||||||
transform: scale(0);
|
transform: scale(0)
|
||||||
}
|
}
|
||||||
|
|
||||||
40% {
|
40% {
|
||||||
transform: scale(1);
|
transform: scale(1)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#version-marker {
|
||||||
|
background-color: white;
|
||||||
|
position: absolute;
|
||||||
|
top: 20px;
|
||||||
|
left: 20px;
|
||||||
|
border-radius: 5px;
|
||||||
|
/* border: 2px solid marker_color */
|
||||||
|
padding: 10px;
|
||||||
|
}
|
||||||
</style>
|
</style>
|
||||||
<style id="pstyle">
|
<style id="pstyle">
|
||||||
</style>
|
</style>
|
||||||
@ -618,6 +628,8 @@
|
|||||||
<body>
|
<body>
|
||||||
<div id="done_target" class="done_target" style="display: none;"></div>
|
<div id="done_target" class="done_target" style="display: none;"></div>
|
||||||
<!-- 用于标记是否完事 默认隐藏-->
|
<!-- 用于标记是否完事 默认隐藏-->
|
||||||
|
<div id="version-marker" style="display: none;"></div>
|
||||||
|
<!-- 左上角一个用于标记版本号的 div, 默认状况下不显示, 部署时使用脚本替换内容, 颜色同理 -->
|
||||||
<img src="thumb.jpg" width="0" height="0" />
|
<img src="thumb.jpg" width="0" height="0" />
|
||||||
<div class='ad_h'></div>
|
<div class='ad_h'></div>
|
||||||
<div class='ad_v'></div>
|
<div class='ad_v'></div>
|
||||||
|
@ -567,6 +567,16 @@
|
|||||||
transform: scale(1);
|
transform: scale(1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#version-marker {
|
||||||
|
background-color: white;
|
||||||
|
position: absolute;
|
||||||
|
top: 20px;
|
||||||
|
left: 20px;
|
||||||
|
border-radius: 5px;
|
||||||
|
/* border: 2px solid marker_color */
|
||||||
|
padding: 10px;
|
||||||
|
}
|
||||||
</style>
|
</style>
|
||||||
<style id="pstyle">
|
<style id="pstyle">
|
||||||
</style>
|
</style>
|
||||||
@ -618,6 +628,8 @@
|
|||||||
<body>
|
<body>
|
||||||
<div id="done_target" class="done_target" style="display: none;"></div>
|
<div id="done_target" class="done_target" style="display: none;"></div>
|
||||||
<!-- 用于标记是否完事 默认隐藏-->
|
<!-- 用于标记是否完事 默认隐藏-->
|
||||||
|
<div id="version-marker" style="display: none;"></div>
|
||||||
|
<!-- 左上角一个用于标记版本号的 div, 默认状况下不显示, 部署时使用脚本替换内容, 颜色同理 -->
|
||||||
<img src="thumb.jpg" width="0" height="0" />
|
<img src="thumb.jpg" width="0" height="0" />
|
||||||
<div class='ad_h'></div>
|
<div class='ad_h'></div>
|
||||||
<div class='ad_v'></div>
|
<div class='ad_v'></div>
|
||||||
|
1730
branch/latest/md5.js
1730
branch/latest/md5.js
File diff suppressed because it is too large
Load Diff
124
deploy.py
Normal file
124
deploy.py
Normal file
@ -0,0 +1,124 @@
|
|||||||
|
import os
|
||||||
|
import random
|
||||||
|
|
||||||
|
from subprocess import run
|
||||||
|
from pathlib import Path
|
||||||
|
|
||||||
|
ON_CF = os.getenv("CF_PAGES") == "1"
|
||||||
|
|
||||||
|
if ON_CF:
|
||||||
|
print("Running on Cloudflare Pages, trying to git fetch --all")
|
||||||
|
result = run(["git", "fetch", "--all"], check=False)
|
||||||
|
print(f"git fetch --all: {result}")
|
||||||
|
# 提前尝试输出一遍下面这堆信息
|
||||||
|
run(["git", "branch", "--show-current"], check=False)
|
||||||
|
run(["git", "rev-parse", "HEAD"], check=False)
|
||||||
|
run(["git", "describe", "--tags"], check=False)
|
||||||
|
run(["git", "log", "-1", "--pretty=%B"], check=False)
|
||||||
|
|
||||||
|
|
||||||
|
def get_env_info() -> dict[str, str]:
|
||||||
|
# 读取环境变量
|
||||||
|
env_info = {}
|
||||||
|
# git branch
|
||||||
|
if ON_CF:
|
||||||
|
branch = os.getenv("CF_PAGES_BRANCH") or "unknown"
|
||||||
|
else:
|
||||||
|
branch = run(
|
||||||
|
["git", "branch", "--show-current"],
|
||||||
|
capture_output=True,
|
||||||
|
text=True,
|
||||||
|
encoding="utf-8",
|
||||||
|
).stdout
|
||||||
|
env_info["branch"] = branch.strip()
|
||||||
|
# git commit hash
|
||||||
|
if ON_CF:
|
||||||
|
commit = os.getenv("CF_PAGES_COMMIT_SHA") or "unknown"
|
||||||
|
else:
|
||||||
|
commit = run(
|
||||||
|
["git", "rev-parse", "HEAD"],
|
||||||
|
capture_output=True,
|
||||||
|
text=True,
|
||||||
|
encoding="utf-8",
|
||||||
|
).stdout
|
||||||
|
env_info["commit"] = commit.strip()
|
||||||
|
# git commit message
|
||||||
|
message = run(
|
||||||
|
["git", "log", "-1", "--pretty=%B"],
|
||||||
|
capture_output=True,
|
||||||
|
text=True,
|
||||||
|
encoding="utf-8",
|
||||||
|
)
|
||||||
|
env_info["message"] = message.stdout.strip()
|
||||||
|
# git tag
|
||||||
|
if ON_CF:
|
||||||
|
tag = run(
|
||||||
|
["git", "describe", "--tags"], capture_output=True, text=True, encoding="utf-8"
|
||||||
|
).stdout.split("-")[0] or "cf_pages"
|
||||||
|
else:
|
||||||
|
tag = run(
|
||||||
|
["git", "describe", "--tags"], capture_output=True, text=True, encoding="utf-8"
|
||||||
|
).stdout.split("-")[0]
|
||||||
|
env_info["tag"] = tag.strip()
|
||||||
|
return env_info
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
# 虽然但是, 我还是决定用 python 写这个脚本
|
||||||
|
|
||||||
|
border_raw = "/* border: 2px solid marker_color */"
|
||||||
|
border_template = "border: 2px solid {};"
|
||||||
|
marker_raw = '<div id="version-marker" style="display: none;"></div>'
|
||||||
|
marker_template = '<div id="version-marker">{}</div>'
|
||||||
|
|
||||||
|
# 读取环境变量
|
||||||
|
env_info = get_env_info()
|
||||||
|
tag = env_info["tag"]
|
||||||
|
branch = env_info["branch"]
|
||||||
|
commit = env_info["commit"]
|
||||||
|
message = env_info["message"]
|
||||||
|
|
||||||
|
for file in Path.cwd().rglob("index.html"):
|
||||||
|
try:
|
||||||
|
with open(file, "r", encoding="utf-8") as f:
|
||||||
|
raw_content = f.read()
|
||||||
|
except Exception as e:
|
||||||
|
print(f"Error: {e}")
|
||||||
|
continue
|
||||||
|
print(f"Reading: {file}")
|
||||||
|
|
||||||
|
# 替换内容
|
||||||
|
# 首先判断是否是 /branch 目录下的 index.html
|
||||||
|
if "branch" in str(file):
|
||||||
|
# 如果是, 则将颜色替换为 random(这里是为了区分不同的分支, 并且颜色相对固定)
|
||||||
|
file_branch_name = file.parent.name
|
||||||
|
randomer = random.Random(file_branch_name)
|
||||||
|
hash_color = randomer.randint(0, 0xFFFFFF)
|
||||||
|
border = border_template.format(f"#{hash_color:06x}")
|
||||||
|
|
||||||
|
# git 信息:
|
||||||
|
version_info = f"{file_branch_name}/{branch}:{tag}-{commit[:6]}<br/>{message}"
|
||||||
|
marker = marker_template.format(version_info)
|
||||||
|
|
||||||
|
print(f"Branch: {file_branch_name}\n{border}\n{marker}\n")
|
||||||
|
|
||||||
|
else:
|
||||||
|
# 淡绿色!
|
||||||
|
border = border_template.format("greenyellow")
|
||||||
|
|
||||||
|
# git 信息:
|
||||||
|
version_info = f"{branch}:{tag}-{commit[:6]}"
|
||||||
|
marker = marker_template.format(version_info)
|
||||||
|
print(f"Master: {border}\n{marker}\n")
|
||||||
|
|
||||||
|
raw_content = raw_content.replace(border_raw, border).replace(
|
||||||
|
marker_raw, marker
|
||||||
|
)
|
||||||
|
|
||||||
|
# 写入文件
|
||||||
|
try:
|
||||||
|
with open(file, "w", encoding="utf-8") as f:
|
||||||
|
f.write(raw_content)
|
||||||
|
except Exception as e:
|
||||||
|
print(f"Error writing file: {e}")
|
||||||
|
continue
|
12
index.html
12
index.html
@ -569,6 +569,16 @@
|
|||||||
transform: scale(1);
|
transform: scale(1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#version-marker {
|
||||||
|
background-color: white;
|
||||||
|
position: absolute;
|
||||||
|
top: 20px;
|
||||||
|
left: 20px;
|
||||||
|
border-radius: 5px;
|
||||||
|
/* border: 2px solid marker_color */
|
||||||
|
padding: 10px;
|
||||||
|
}
|
||||||
</style>
|
</style>
|
||||||
<style id="pstyle">
|
<style id="pstyle">
|
||||||
</style>
|
</style>
|
||||||
@ -620,6 +630,8 @@
|
|||||||
<body>
|
<body>
|
||||||
<div id="done_target" class="done_target" style="display: none;"></div>
|
<div id="done_target" class="done_target" style="display: none;"></div>
|
||||||
<!-- 用于标记是否完事 默认隐藏-->
|
<!-- 用于标记是否完事 默认隐藏-->
|
||||||
|
<div id="version-marker" style="display: none;"></div>
|
||||||
|
<!-- 左上角一个用于标记版本号的 div, 默认状况下不显示, 部署时使用脚本替换内容, 颜色同理 -->
|
||||||
<img src="thumb.jpg" width="0" height="0" />
|
<img src="thumb.jpg" width="0" height="0" />
|
||||||
<div class='ad_h'></div>
|
<div class='ad_h'></div>
|
||||||
<div class='ad_v'></div>
|
<div class='ad_v'></div>
|
||||||
|
Loading…
Reference in New Issue
Block a user