@@ -115,6 +115,60 @@ jobs:
115115 echo "ZASHBOARD_EOF"
116116 } >> "$GITHUB_OUTPUT"
117117
118+ - name : 更新 sing-box Dashboard
119+ id : singbox_dashboard
120+ env :
121+ GH_TOKEN : ${{ secrets.GITHUB_TOKEN }}
122+ run : |
123+ repo="$(jq -r '.githubArchive[0].repo' .github/resources.json)"
124+ ref="$(jq -r '.githubArchive[0].ref' .github/resources.json)"
125+ dest="$(jq -r '.githubArchive[0].path' .github/resources.json)"
126+ current="$(jq -r '.githubArchive[0].currentCommit' .github/resources.json)"
127+ latest="$(gh api "repos/${repo}/commits/${ref}" --jq '.sha')"
128+
129+ echo "sing-box Dashboard 当前: '${current:-无}',最新: '$latest'"
130+
131+ summary=""
132+ if [ "$latest" != "$current" ]; then
133+ echo "发现上游更新,开始同步..."
134+ rm -rf tmp-sing-box-dashboard
135+ mkdir -p tmp-sing-box-dashboard/extract
136+
137+ if curl -fsSL --retry 3 --connect-timeout 15 \
138+ "https://github.com/${repo}/archive/${latest}.zip" \
139+ -o tmp-sing-box-dashboard/dashboard.zip; then
140+ unzip -q tmp-sing-box-dashboard/dashboard.zip -d tmp-sing-box-dashboard/extract
141+ srcdir="$(find tmp-sing-box-dashboard/extract -mindepth 1 -maxdepth 1 -type d | head -n 1)"
142+
143+ if [ -n "$srcdir" ] && [ -f "$srcdir/index.html" ]; then
144+ rm -rf "$dest"
145+ mkdir -p "$dest"
146+ cp -r "$srcdir"/. "$dest"/
147+
148+ tmpjson="$(mktemp)"
149+ jq --arg commit "$latest" \
150+ '.githubArchive[0].currentCommit = $commit' \
151+ .github/resources.json > "$tmpjson"
152+ mv "$tmpjson" .github/resources.json
153+ summary="- ${dest}:sing-box Dashboard ${current:0:7} → ${latest:0:7}"
154+ else
155+ echo "::warning::归档中没有找到 Dashboard 入口文件,跳过更新"
156+ fi
157+ else
158+ echo "::warning::下载 sing-box Dashboard 失败,跳过更新"
159+ fi
160+
161+ rm -rf tmp-sing-box-dashboard
162+ else
163+ echo "已是最新,跳过"
164+ fi
165+
166+ {
167+ echo "summary<<SING_BOX_DASHBOARD_EOF"
168+ printf '%s\n' "$summary"
169+ echo "SING_BOX_DASHBOARD_EOF"
170+ } >> "$GITHUB_OUTPUT"
171+
118172 - name : 更新 npm 依赖
119173 id : npm
120174 run : |
@@ -230,6 +284,7 @@ jobs:
230284 ### 内置资源
231285 ${{ steps.raw.outputs.summary }}
232286 ${{ steps.zashboard.outputs.summary }}
287+ ${{ steps.singbox_dashboard.outputs.summary }}
233288
234289 ### npm 依赖
235290 ${{ steps.npm.outputs.summary }}
0 commit comments