Sync and Compile IPTV Mainland Rules #10
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Sync and Compile IPTV Mainland Rules | |
on: | |
schedule: | |
- cron: '0 18 * * *' # 每天北京时间02:00执行 | |
workflow_dispatch: | |
permissions: | |
contents: write | |
jobs: | |
iptv_rules: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout the repository | |
uses: actions/checkout@v4 | |
with: | |
token: ${{ secrets.GITHUB_TOKEN }} | |
- name: Set up Git user | |
run: | | |
git config user.name "github-actions[bot]" | |
git config user.email "github-actions[bot]@users.noreply.github.com" | |
- name: Install mihomo | |
run: | | |
version=$(curl -sL https://github.com/MetaCubeX/mihomo/releases/download/Prerelease-Alpha/version.txt) | |
curl -sL "https://github.com/MetaCubeX/mihomo/releases/download/Prerelease-Alpha/mihomo-linux-amd64-${version}.gz" | \ | |
gunzip -c > /usr/local/bin/mihomo && chmod +x /usr/local/bin/mihomo | |
- name: Fetch IPTV Mainland Rules | |
run: | | |
mkdir -p rules/Domain # 确保目录存在 | |
# 下载 IPTV Mainland 规则文件 | |
curl -sL "https://raw.githubusercontent.com/Aethersailor/Custom_OpenClash_Rules/refs/heads/main/rule/IPTVMainland_Domain.list" -o rules/Domain/iptv.list | |
- name: Convert IPTV Mainland Rules to YAML | |
run: | | |
echo "payload:" > rules/Domain/iptv_combined.yaml | |
while IFS=, read -r type value; do | |
if [[ -n "$type" && -n "$value" ]]; then | |
echo " - $value" >> rules/Domain/iptv_combined.yaml | |
fi | |
done < rules/Domain/iptv.list | |
- name: Convert IPTV Mainland Rules to MRS | |
run: | | |
# 使用 mihomo 转换为 MRS 格式 | |
mihomo convert-ruleset domain yaml rules/Domain/iptv_combined.yaml rules/Domain/iptv.mrs | |
rm -f rules/Domain/iptv.list rules/Domain/iptv_combined.yaml | |
- name: Commit and Push Changes | |
run: | | |
git add . | |
git diff-index --quiet HEAD -- || (git commit -m "Updated IPTV Mainland rules (iptv.list -> iptv.mrs)" && git push) |