Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions .github/workflows/collect-on-push.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: Collect after dashboard changes

on:
push:
branches: [main]
paths-ignore: ['site/**', '.sync/**']

permissions:
contents: read
actions: write

jobs:
dispatch:
runs-on: ubuntu-latest
timeout-minutes: 5
steps:
- name: Dispatch collection on main
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GH_REPO: ${{ github.repository }}
COLLECTION_REQUEST_ID: push-${{ github.sha }}
# The collector's OIDC trust accepts workflow_dispatch, not push.
run: gh workflow run collect.yml --repo "$GH_REPO" --ref main --raw-field "request_id=$COLLECTION_REQUEST_ID"
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

## 使用

在目标仓 Actions 手动运行 **Collect dashboard data**,或由 Bot 触发;每小时第 17、47 分钟自动续跑。采集提交 `site/` 后,**Deploy dashboard Pages** 发布站点。首次配置见 [Actions 采集](docs/actions-collection.md)。
在目标仓 Actions 手动运行 **Collect dashboard data**,或由 Bot 触发;每小时第 17、47 分钟自动续跑。`main` 上包含 `site/`、`.sync/` 以外文件改动的推送,也会自动派发一次采集;仅改这两个目录的采集提交不会再次派发。采集提交 `site/` 后,**Deploy dashboard Pages** 发布站点。首次配置见 [Actions 采集](docs/actions-collection.md)。

本地快速预览(Python 3.10+,凭据来自环境或已登录的 gh):

Expand Down
4 changes: 4 additions & 0 deletions docs/actions-collection.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ App 的 Actions 写权限在 App 注册页 **Permissions & events → Repository

工作流接受 `workflow_dispatch`,并在每小时第 17、47 分钟定时续跑;固定 checkout main,禁止 checkout 输入指定的任意分支。输入 `source_repository` 可省略,填写时必须匹配本站源仓;`request_id` 为诊断用刷新编号,不包含原始 Webhook、私钥或安装令牌。可在 Actions 的 **Collect dashboard data** 手动执行,也可以由 Bot 调用 GitHub workflow dispatch API。

`collect-on-push.yml` 在 `main` 收到包含 `site/`、`.sync/` 以外文件改动的推送时,自动派发 `collect.yml` 的 `workflow_dispatch`,固定 `ref=main`,`request_id=push-<完整提交 SHA>`,不传 `source_repository`。它使用本仓 `GITHUB_TOKEN`,仅声明 `contents: read` 和 `actions: write`;不在 PR 上运行,也不取消正在执行的采集。`paths-ignore` 排除 `site/**` 与 `.sync/**`,因此只修改这两个目录的采集提交不会再次派发;源码与数据混合的推送仍会触发。定时、手动及 Bot 触发保持不变,Pages 仍由 `site/` 的提交触发。

不要直接给 `collect.yml` 增加 `push`:Worker 的 OIDC 校验只接受该工作流的 `schedule` 和 `workflow_dispatch`,直接由 `push` 启动会在领取令牌时被拒绝。派发工作流只负责调度,不领取采集凭据;采集串行和等待队列仍由 `collect-${{ github.repository }}` 并发组管理。

兑换令牌后,客户端用同一 OIDC 身份向同一 Worker 的 `/actions/gitcode-sync` 读取 GitCode 同步记录,经 `GSB_GITCODE_SYNC_FILE` 交给发布器;读取失败只把页面标为过期,不影响采集。见 [GitCode 同步记录](gitcode-sync.md)。

采集步骤从环境变量读取源仓 `GITHUB_TOKEN` 和目标仓 `GSB_PUBLISH_TOKEN`,运行 `publish.py --repo ... --publish-repo ... --output .tmp/collected-site --incremental`。临时目录不上传,不写回原始测试 artifact。发布器基于本轮 checkout 的准确 HEAD,将 `.sync/` 进度及变化的 `site/` 分片放入一个 Git 提交。保留源码和工作流;并发冲突直接失败,下轮从新 main 续跑。只有 site 变化才触发 Pages。详情见 [增量同步](incremental-history.md)。
Expand Down
Loading