Skip to content

Commit 526af60

Browse files
VerseOSVerseOS
authored andcommitted
feat: add OPML auto-clean and sync workflow
1 parent 4b2649f commit 526af60

5 files changed

Lines changed: 747 additions & 2 deletions

File tree

.github/workflows/opml-sync.yml

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
name: OPML Sync
2+
3+
on:
4+
push:
5+
branches:
6+
- master
7+
pull_request:
8+
branches:
9+
- master
10+
11+
jobs:
12+
check:
13+
if: github.event_name == 'pull_request'
14+
runs-on: ubuntu-latest
15+
permissions:
16+
contents: read
17+
steps:
18+
- name: Checkout
19+
uses: actions/checkout@v4
20+
21+
- name: Setup Python
22+
uses: actions/setup-python@v5
23+
with:
24+
python-version: "3.11"
25+
26+
- name: Run unit tests
27+
run: python -m unittest discover -s tests -v
28+
29+
- name: Run OPML check mode
30+
run: |
31+
python scripts/opml_sync.py \
32+
--mode check \
33+
--tiny tiny.opml \
34+
--full CyberSecurityRSS.opml \
35+
--fallback-category Misc \
36+
--timeout 10 \
37+
--retries 3
38+
39+
apply:
40+
if: github.event_name == 'push' && github.actor != 'github-actions[bot]'
41+
runs-on: ubuntu-latest
42+
permissions:
43+
contents: write
44+
steps:
45+
- name: Checkout
46+
uses: actions/checkout@v4
47+
48+
- name: Setup Python
49+
uses: actions/setup-python@v5
50+
with:
51+
python-version: "3.11"
52+
53+
- name: Run unit tests
54+
run: python -m unittest discover -s tests -v
55+
56+
- name: Run OPML apply mode
57+
run: |
58+
python scripts/opml_sync.py \
59+
--mode apply \
60+
--tiny tiny.opml \
61+
--full CyberSecurityRSS.opml \
62+
--fallback-category Misc \
63+
--timeout 10 \
64+
--retries 3
65+
66+
- name: Commit and push changes
67+
run: |
68+
if git diff --quiet; then
69+
echo "No OPML changes detected."
70+
exit 0
71+
fi
72+
git config user.name "github-actions[bot]"
73+
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
74+
git add tiny.opml CyberSecurityRSS.opml
75+
git commit -m "chore: auto-clean OPML feeds and sync from tiny [skip ci]"
76+
git push

README.md

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,11 +53,21 @@ Use the same way as Usage 1
5353

5454
![7.png](https://i.loli.net/2021/02/10/pHdIEztoOUeVxv3.png)
5555

56+
## Automation
57+
58+
This repository uses GitHub Actions to keep OPML files healthy and synced:
59+
60+
1. On `pull_request` to `master`, workflow runs in `check` mode and fails when OPML drift is detected.
61+
2. On `push` to `master`, workflow runs in `apply` mode:
62+
- Validate RSS/Atom feed URLs in `tiny.opml` and `CyberSecurityRSS.opml`.
63+
- Remove dead feed entries and deduplicate by `xmlUrl`.
64+
- Sync valid feeds from `tiny.opml` into `CyberSecurityRSS.opml` (missing categories fall back to `Misc`).
65+
- Auto-commit OPML changes with `[skip ci]`.
66+
5667
## Contribution
5768

5869
If you find a great site, please submit an issue or pr
5970

6071
## Sponsor
6172

6273
[![Powered by DartNode](https://dartnode.com/branding/DN-Open-Source-sm.png)](https://dartnode.com "Powered by DartNode - Free VPS for Open Source")
63-

README.zh-CN.md

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,11 +53,21 @@ cp tiny.opml tiny.xml
5353

5454
![7.png](https://i.loli.net/2021/02/10/pHdIEztoOUeVxv3.png)
5555

56+
## 自动化工作流
57+
58+
仓库已配置 GitHub Actions 自动维护 OPML:
59+
60+
1. `pull_request -> master` 触发 `check` 模式,只校验不改文件;如发现需要变更会直接失败。
61+
2. `push -> master` 触发 `apply` 模式,自动执行:
62+
- 校验 `tiny.opml``CyberSecurityRSS.opml` 的 RSS/Atom 链接可访问性。
63+
- 删除失效订阅,并按 `xmlUrl` 自动去重。
64+
-`tiny.opml` 中有效且大表缺失的链接同步到 `CyberSecurityRSS.opml`
65+
- 若分类不存在则归入 `Misc`,并自动提交修复结果(commit 含 `[skip ci]`)。
66+
5667
## 附录
5768

5869
others.md中是我一般会主动浏览的站点并且一些站点没有提供rss的都写在了里面。
5970

6071
## 贡献
6172

6273
如果大家还有很棒的站点欢迎提issue
63-

0 commit comments

Comments
 (0)