graph TD
A[Push to master] --> B[触发工作流]
B --> C{是否自动发布提交?}
C -->|是| D[跳过退出]
C -->|否| E{Gatekeeper: 是否已有 Release 标签?}
E -->|是| D
E -->|否| F[Checkout + Setup Node.js]
F --> G[Hexo 生成静态文件]
G --> H[打包 public/ 为 tar.gz]
H --> I[创建 Release 并上传附件]
I --> J[同步 public/ 到公网服务器]
各步骤说明
1. 触发条件
1 2 3 4
on: push: branches: -master
仅监听 master 分支的推送事件。
2. 防护机制
跳过自动发布提交: 含有 Auto release 关键词的提交不会触发,防止 Release 创建事件产生死循环。
Gatekeeper 标签检查: 从远端同步最新标签后,检测当前 commit 是否已有 v- 开头的标签。如果存在,说明本次触发是 Release API 产生的二次调用,直接安全退出。
# 🌟 Gatekeeper: local Git tag check to prevent re-trigger loops -name:🛡️Anti-LoopGatekeeper run:| # Force sync tags from remote to avoid Gitea cache staleness git fetch --tags --force CURRENT_COMMIT=$(gitrev-parse--shortHEAD) echo"Current Commit ID: $CURRENT_COMMIT"
# Get all tags pointing to the current commit ALL_TAGS=$(gittag--points-atHEAD) echo"Tags on this commit: $ALL_TAGS"
# Check if any auto-release tag (v-*) exists on this commit ifecho"$ALL_TAGS"|grep-q"v-";then echo"=========================================================" echo"🚨 [Blocked] Auto-release tag already exists on this commit." echo"🚨 This run is likely a re-trigger caused by the Release API. Exiting safely." echo"=========================================================" exit0# 🌟 Exit cleanly to cancel all subsequent steps fi