添加部署时间

This commit is contained in:
董海洋
2026-06-01 17:53:50 +08:00
parent f63736fba6
commit 703f12209e
2 changed files with 8 additions and 9 deletions
+6 -5
View File
@@ -55,8 +55,7 @@ log_info "构建文档..."
npm run docs:build
log_info "部署静态文件到 Nginx 目录..."
rm -rf "${NGINX_ROOT:?}"/*
# cp -r dist-docs/* "${NGINX_ROOT}/"
# rm -rf "${NGINX_ROOT:?}"/*
# =============== 生成部署历史记录 ===============
if [ "${PREV_COMMIT}" != "${NEW_COMMIT}" ]; then
log_info "生成部署历史记录..."
@@ -80,6 +79,7 @@ if [ "${PREV_COMMIT}" != "${NEW_COMMIT}" ]; then
h1{font-size:20px;color:#222;margin-bottom:20px;border-bottom:1px solid #eee;padding-bottom:10px}
.commit-item{padding:15px;border-left:4px solid #2563eb;margin-bottom:12px;background:#f8fafc;border-radius:6px}
.commit-hash{font-family:monospace;color:#2563eb;font-weight:bold;font-size:14px}
.deploy-time{font-size:13px;color:#16a34a;margin:4px 0;font-weight:bold}
.commit-time{font-size:13px;color:#666;margin:4px 0}
.commit-author{font-size:13px;color:#555}
.commit-msg{margin:6px 0;color:#333}
@@ -94,10 +94,11 @@ if [ "${PREV_COMMIT}" != "${NEW_COMMIT}" ]; then
HTML
fi
# 生成本次提交的详细信息区块
# 生成本次提交的详细信息区块(按时间倒序,最新的在最前面)
TEMP_CONTENT=$(git log --pretty=format:" \
<div class='commit-item'> \
<div class='commit-hash'>%h</div> \
<div class='deploy-time'>部署时间:${DEPLOY_TIME}</div> \
<div class='commit-time'>提交时间:%ad</div> \
<div class='commit-author'>提交人:%an</div> \
<div class='commit-msg'>提交说明:%s</div> \
@@ -106,9 +107,9 @@ HTML
--date=format:"%Y-%m-%d %H:%M:%S" \
"${PREV_COMMIT}..${NEW_COMMIT}")
# 将新内容追加到页面中(在 </div></body></html> 之前插入)
# 将新内容插入到 commitList 的开头(最新的在最上面)
sed -i -e '/<\/div><\/body><\/html>/d' "${LOG_PAGE}"
echo "${TEMP_CONTENT}" >> "${LOG_PAGE}"
sed -i -e '/<div id="commitList">/r /dev/stdin' "${LOG_PAGE}" <<< "${TEMP_CONTENT}"
echo "</div></body></html>" >> "${LOG_PAGE}"
fi