Compare commits
85 Commits
401dcddb10
...
e5e8234fef
Author | SHA1 | Date | |
---|---|---|---|
e5e8234fef | |||
78227bba31 | |||
5195bac03a | |||
cf0a30d7e6 | |||
f822b0ca27 | |||
9459a6ebaa | |||
45e43f3629 | |||
f04ea68d3b | |||
dfc4f1f2d5 | |||
4f94d26c23 | |||
45d13a27d2 | |||
cb2273be12 | |||
633844d7ac | |||
bc362d0809 | |||
39e9d32c4d | |||
2c3a079dff | |||
7642d78c7d | |||
d26b58f7d8 | |||
7d2c85da3d | |||
ccfa58e435 | |||
4400e2c28f | |||
b3eaeeab1e | |||
12749868da | |||
943987020d | |||
a63d57cb9f | |||
0f47df33dd | |||
68a4f791c5 | |||
b6c7757c1f | |||
2faee3115c | |||
b0c39b8c74 | |||
ddb1274d52 | |||
f16f67d33a | |||
7d635e6d04 | |||
1ac326504c | |||
3737ba2264 | |||
d5655eab6c | |||
62dff4d569 | |||
ead50b9d53 | |||
1ca7919388 | |||
9c8d4c4091 | |||
4829294cf2 | |||
901115db22 | |||
a5b49557e9 | |||
8ebf75e828 | |||
f941f6c253 | |||
748f89c292 | |||
27a090b761 | |||
9949a9a4a0 | |||
07daf8610e | |||
a67457f16a | |||
ca0c26c01c | |||
efc3b6acfb | |||
162caf6f17 | |||
3ac587b2eb | |||
f9db7fde67 | |||
47571e35c0 | |||
9824aa1f2f | |||
d50eea4292 | |||
735b6db67e | |||
41c3efe023 | |||
b5ac69eff0 | |||
a2c223484c | |||
bf4033618c | |||
1e80479530 | |||
6e95ed0adb | |||
de2925c61e | |||
b16f0dd393 | |||
f2fc5233d3 | |||
829e8c15e0 | |||
c8d2160f29 | |||
bd80287940 | |||
14a25539b9 | |||
ce61c7fb5e | |||
830b9949db | |||
edddabd79d | |||
40cce66619 | |||
0cd5fe2b3d | |||
f4f0425fd4 | |||
a1b9a989e6 | |||
ac8b9dcf90 | |||
1bc318528c | |||
241a432677 | |||
d09d89bb57 | |||
7484b7abbc | |||
ee73fa621f |
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>
|
||||||
|
1626
branch/latest/md5.js
1626
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