增加 Release 自动同步 workflow

This commit is contained in:
2026-08-21 17:48:19 +08:00
parent d3e19bcc46
commit 1e5b2d0b99
6 changed files with 683 additions and 5 deletions
+92
View File
@@ -0,0 +1,92 @@
name: 同步 skill Releases
on:
schedule:
- cron: "17 * * * *"
workflow_dispatch:
concurrency:
group: sync-skill-releases
cancel-in-progress: false
permissions:
contents: write
jobs:
sync:
runs-on: ubuntu-latest
steps:
- name: 检出分发仓
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
fetch-depth: 0
persist-credentials: false
- name: 检查同步凭据
env:
SOURCE_REPOS_TOKEN: ${{ secrets.AGENT_SKILL_BOT }}
run: |
set -eu
test -n "$SOURCE_REPOS_TOKEN" || {
echo "缺少组织 Actions secret:AGENT_SKILL_BOT"
exit 1
}
- name: 同步 latest Releases
env:
GITEA_SERVER_URL: ${{ github.server_url }}
SOURCE_REPOS_TOKEN: ${{ secrets.AGENT_SKILL_BOT }}
run: python3 scripts/sync-releases.py
- name: 校验分发仓
run: |
set -eu
python3 scripts/validate-dist.py
NO_COLOR=1 npx --yes skills@1.5.22 add . --list | tee /tmp/skills-list.txt
python3 - <<'PY'
from pathlib import Path
expected = {
"baimiao-table-ocr",
"disk-master",
"everything-file-search",
"teach-me",
"think-twice",
}
output = Path("/tmp/skills-list.txt").read_text(encoding="utf-8")
lines = {line.strip(" │└├─") for line in output.splitlines()}
missing = sorted(expected - lines)
if missing:
raise SystemExit(f"skills CLI 未发现:{', '.join(missing)}")
print(f"skills CLI 已发现全部 {len(expected)} 个 skill")
PY
- name: 提交同步结果
env:
GITEA_TOKEN: ${{ secrets.GITEA_TOKEN }}
GITEA_SERVER_URL: ${{ github.server_url }}
run: |
set -eu
if git diff --quiet -- .dist-sync skills; then
echo "latest Releases 没有产生内容变化"
exit 0
fi
git config user.name "Agent Skills Bot"
git config user.email "agent-skills-bot@im0o.top"
git add .dist-sync skills
git commit -m "同步 latest skill releases"
auth=$(printf 'x-access-token:%s' "$GITEA_TOKEN" | base64 | tr -d '\n')
server_url=${GITEA_SERVER_URL%/}
git_auth() {
git -c "http.${server_url}/.extraheader=Authorization: Basic $auth" "$@"
}
git_auth fetch origin main
test "$(git rev-parse HEAD^)" = "$(git rev-parse origin/main)" || {
echo "origin/main 已前进,本次不自动变基或强制推送"
exit 1
}
git_auth push origin HEAD:main