Skip to content

Commit 1595ca1

Browse files
committed
refactor(ci): consolidate repository workflows
1 parent af2ad6b commit 1595ca1

10 files changed

Lines changed: 54 additions & 115 deletions

.github/workflows/README.md

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,17 +9,15 @@
99
| 文件名 | 描述 | 触发条件 |
1010
| :--- | :--- | :--- |
1111
| [`auto-backup-wiki.yml`](auto-backup-wiki.yml) | 校验 Wiki 目录页和页面完整性后,事务式备份到仓库的 `wiki/` 目录并处理链接替换 | 每 2 小时或手动触发 |
12-
| [`auto-generate-rules.yml`](auto-generate-rules.yml) |`rule/` 顶层和 `rule/game_rule/``.list` 规则源统一生成 `.yaml``.mrs` 派生规则,清理失去来源的派生文件,并在精确 SHA 校验成功后调用统一 CDN 发布器 | 对应规则源或生成器变更、源更新工作流同步调用,或手动触发 |
12+
| [`auto-generate-rules.yml`](auto-generate-rules.yml) |`.list` 规则源统一生成 `.yaml``.mrs` 派生规则,并由受维护的 Clash 模板同步生成 Mainland 与 Stash 兼容文件;完成精确 SHA 校验后调用统一 CDN 发布器 | 对应规则源、模板或生成器变更,源更新工作流同步调用,或手动触发 |
1313
| [`auto-update-encrypted-dns.yml`](auto-update-encrypted-dns.yml) | 从 HaGeZi、DNSCrypt 和编译后的 `geosite:category-doh` 自动更新 `Encrypted_DNS.list`;内容变化后同步等待派生规则生成,派生失败会使本工作流失败 | 每日或手动触发 |
1414
| [`auto-update-game-cdn.yml`](auto-update-game-cdn.yml) | 合并 v2fly 上游与本项目 `Steam_CDN.list`,智能去重后更新 `Game_Download_CDN.list`;内容变化后同步等待派生规则生成 | `Steam_CDN.list` 或生成器变更、每日或手动触发 |
15-
| [`auto-update-mainland.yml`](auto-update-mainland.yml) |`Custom_Clash.ini` 同步为兼容文件 `Custom_Clash_Mainland.ini`,并在内容变化时发布 | `Custom_Clash.ini` 变更或手动触发 |
1615
| [`codeql.yml`](codeql.yml) | 使用扩展安全与质量查询分析 GitHub Actions 和 Python | 相关代码推送、Pull Request、每日或手动触发 |
17-
| [`dependabot-auto-merge.yml`](dependabot-auto-merge.yml) | 等待 Validate、Dependency Review 和 CodeQL 全部成功后,自动压缩合并(squash merge)带有 `automerge` 标签的 Dependabot PR | 上述检查完成 |
18-
| [`dependency-review.yml`](dependency-review.yml) | 阻止 PR 引入任何已知等级的漏洞依赖,并展示 OpenSSF Scorecard 信息 | Pull Request |
16+
| [`dependabot-auto-merge.yml`](dependabot-auto-merge.yml) | 等待 Validate(含 Dependency Review)和 CodeQL 全部成功后,自动压缩合并(squash merge)带有 `automerge` 标签的 Dependabot PR | 上述检查完成 |
1917
| [`pages.yml`](pages.yml) | 构建并部署 MkDocs 文档站点到 GitHub Pages | `wiki/**``mkdocs.yml` 变更或手动触发 |
2018
| [`purge-jsdelivr.yml`](purge-jsdelivr.yml) |[公开发布契约](../jsdelivr-publish.json) 精确刷新 jsDelivr 缓存;生成内容完整、精确 SHA 校验成功且仍为最新 `main` 时,同步部署 Cloudflare Static Assets 热备快照 | `main` 分支推送、规则生成且校验成功,或手动修复范围 |
2119
| [`sync-openclash-overwrite-submodule.yml`](sync-openclash-overwrite-submodule.yml) |`overwrite/OpenClash_Overwrite` 子模块同步到上游 `main` 分支 | 每 2 小时或手动触发 |
22-
| [`validate.yml`](validate.yml) | 校验 Shell、Python、Sub-Store、Wiki 备份、规则派生文件、MRS、完整 Mihomo 模板和 Cloudflare 镜像部署包;也可由发布器校验指定提交 | 代码推送、Pull Request、发布器同步调用或手动触发 |
20+
| [`validate.yml`](validate.yml) | 校验 Shell、Python、Sub-Store、Wiki 备份、规则派生文件、MRS、完整 Mihomo 模板和 Cloudflare 镜像部署包;Pull Request 还会执行 Dependency Review,也可由发布器校验指定提交 | 代码推送、Pull Request、发布器同步调用或手动触发 |
2321

2422
## Cloudflare 热备发布
2523

.github/workflows/auto-generate-rules.yml

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,14 @@ on:
1919
- 'rule/game_rule/**/*.list'
2020
- 'py/generate_rules.py'
2121
- 'py/generate_stash_configs.py'
22-
- 'cfg/Custom_Clash*.ini'
22+
- 'cfg/Custom_Clash.ini'
23+
- 'cfg/Custom_Clash_Fallback.ini'
24+
- 'cfg/Custom_Clash_Lite.ini'
25+
- 'cfg/Custom_Clash_Lite_Fallback.ini'
26+
- 'cfg/Custom_Clash_GFW.ini'
27+
- 'cfg/Custom_Clash_GFW_Fallback.ini'
28+
- 'cfg/Custom_Clash_Full.ini'
29+
- 'cfg/Custom_Clash_Full_Fallback.ini'
2330
workflow_dispatch:
2431
inputs:
2532
source_before_sha:
@@ -102,13 +109,15 @@ jobs:
102109
':(glob)rule/*.mrs'
103110
':(glob)rule/game_rule/**/*.yaml'
104111
':(glob)rule/game_rule/**/*.mrs'
112+
'cfg/Custom_Clash_Mainland.ini'
105113
':(glob)cfg/Custom_Stash*.ini'
106114
)
107115
generated_excludes=(
108116
':(exclude,glob)rule/*.yaml'
109117
':(exclude,glob)rule/*.mrs'
110118
':(exclude,glob)rule/game_rule/**/*.yaml'
111119
':(exclude,glob)rule/game_rule/**/*.mrs'
120+
':(exclude)cfg/Custom_Clash_Mainland.ini'
112121
':(exclude,glob)cfg/Custom_Stash*.ini'
113122
)
114123
remote_main_sha() {

.github/workflows/auto-update-mainland.yml

Lines changed: 0 additions & 71 deletions
This file was deleted.

.github/workflows/dependabot-auto-merge.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ on:
44
workflow_run:
55
workflows:
66
- CodeQL Advanced
7-
- Dependency Review
87
- Validate repository
98
types: [completed]
109
branches:

.github/workflows/dependency-review.yml

Lines changed: 0 additions & 29 deletions
This file was deleted.

.github/workflows/validate.yml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ on:
1818
- 'shell/**/*.sh'
1919
- 'cfg/*.ini'
2020
- 'cfg/yaml/**'
21+
- 'requirements*.txt'
2122
- 'workers/repository-mirror/**'
2223
pull_request:
2324
branches:
@@ -35,6 +36,7 @@ on:
3536
- 'shell/**/*.sh'
3637
- 'cfg/*.ini'
3738
- 'cfg/yaml/**'
39+
- 'requirements*.txt'
3840
- 'workers/repository-mirror/**'
3941
workflow_dispatch:
4042

@@ -49,6 +51,22 @@ concurrency:
4951
cancel-in-progress: true
5052

5153
jobs:
54+
dependency-review:
55+
if: github.event_name == 'pull_request'
56+
runs-on: ubuntu-latest
57+
timeout-minutes: 10
58+
steps:
59+
- name: Reject newly introduced vulnerable dependencies
60+
uses: actions/dependency-review-action@a1d282b36b6f3519aa1f3fc636f609c47dddb294 # v5.0.0
61+
with:
62+
fail-on-severity: low
63+
fail-on-scopes: development, runtime, unknown
64+
retry-on-snapshot-warnings: true
65+
retry-on-snapshot-warnings-timeout: 120
66+
show-openssf-scorecard: true
67+
warn-on-openssf-scorecard-level: 5
68+
show-patched-versions: true
69+
5270
validate:
5371
runs-on: ubuntu-latest
5472
timeout-minutes: 15

cfg/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ OpenClash `dev` 分支的内置列表已收录本仓库全部 8 个模板的远
5050
| 重度分流版 | [`Custom_Clash_Full.ini`](./Custom_Clash_Full.ini) | 业务、地区和节点用途分组更丰富 |
5151
| 重度分流故障转移版 | [`Custom_Clash_Full_Fallback.ini`](./Custom_Clash_Full_Fallback.ini) | 重度分流结构与自动故障转移结合 |
5252

53-
[`Custom_Clash_Mainland.ini`](./Custom_Clash_Mainland.ini) 是由工作流从 `Custom_Clash.ini` 自动同步的兼容文件,不是独立配置版本。不要直接修改该文件。
53+
[`Custom_Clash_Mainland.ini`](./Custom_Clash_Mainland.ini) 是由统一兼容配置生成流程从 `Custom_Clash.ini` 自动同步的文件,不是独立配置版本。不要直接修改该文件。
5454

5555
## 📊 版本区别
5656

py/archived/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414

1515
- **功能:**`cfg/Custom_Clash.ini` 复制为 `cfg/Custom_Clash_Mainland.ini`
1616
- **状态:** 已归档。
17-
- **原因:** 当前由 `auto-update-mainland.yml` 直接完成同步,不再需要独立 Python 脚本
17+
- **原因:** 当前由 `py/generate_stash_configs.py` 通过统一兼容配置生成流程完成同步,不再需要独立脚本
1818

1919
> [!WARNING]
2020
> 归档脚本仅用于追溯旧实现,不应参与当前生成或发布流程。

py/generate_stash_configs.py

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#!/usr/bin/env python3
2-
"""Generate Stash-specific subconverter templates from maintained Clash policy."""
2+
"""Generate tracked compatibility templates from maintained Clash policy."""
33

44
from __future__ import annotations
55

@@ -395,8 +395,16 @@ def generated_outputs(root: Path) -> dict[Path, str]:
395395
return outputs
396396

397397

398+
def compatibility_outputs(root: Path) -> dict[Path, str]:
399+
outputs = generated_outputs(root)
400+
outputs[Path("cfg/Custom_Clash_Mainland.ini")] = (
401+
root / "cfg" / "Custom_Clash.ini"
402+
).read_text(encoding="utf-8")
403+
return outputs
404+
405+
398406
def check_outputs(root: Path, outputs: dict[Path, str] | None = None) -> tuple[Path, ...]:
399-
expected = outputs if outputs is not None else generated_outputs(root)
407+
expected = outputs if outputs is not None else compatibility_outputs(root)
400408
mismatches = []
401409
for relative_path, content in expected.items():
402410
path = root / relative_path
@@ -410,14 +418,14 @@ def main() -> int:
410418
parser.add_argument("--check", action="store_true", help="check committed outputs")
411419
args = parser.parse_args()
412420
root = Path(__file__).resolve().parents[1]
413-
outputs = generated_outputs(root)
421+
outputs = compatibility_outputs(root)
414422
if args.check:
415423
mismatches = check_outputs(root, outputs)
416424
if mismatches:
417425
for path in mismatches:
418-
print(f"outdated generated Stash template: {path.as_posix()}")
426+
print(f"outdated generated compatibility template: {path.as_posix()}")
419427
return 1
420-
print("generated Stash templates are current")
428+
print("generated compatibility templates are current")
421429
return 0
422430

423431
for relative_path, content in outputs.items():

py/test_rule_generation.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -228,10 +228,17 @@ def test_generates_nine_deterministic_outputs(self) -> None:
228228

229229
def test_committed_outputs_are_current(self) -> None:
230230
self.assertEqual(
231-
generate_stash_configs.check_outputs(self.root, self.outputs),
231+
generate_stash_configs.check_outputs(self.root),
232232
(),
233233
)
234234

235+
def test_clash_mainland_compatibility_output_matches_standard(self) -> None:
236+
outputs = generate_stash_configs.compatibility_outputs(self.root)
237+
self.assertEqual(
238+
outputs[Path("cfg/Custom_Clash_Mainland.ini")],
239+
(self.root / "cfg/Custom_Clash.ini").read_text(encoding="utf-8"),
240+
)
241+
235242
def test_projects_stash_rules_without_silent_unsupported_rules(self) -> None:
236243
for relative_path, content in self.outputs.items():
237244
with self.subTest(path=relative_path):

0 commit comments

Comments
 (0)