Skip to content

Sync and Compile WeChat Rules #13

Sync and Compile WeChat Rules

Sync and Compile WeChat Rules #13

Workflow file for this run

name: Sync and Compile WeChat Rules
on:
schedule:
- cron: '0 18 * * *' # 北京时间 02:00 执行
workflow_dispatch:
permissions:
contents: write
jobs:
wechat_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 WeChat Rules
run: |
mkdir -p rules/Domain # 确保目录存在
# 下载 WeChat 规则文件
curl -sL "https://raw.githubusercontent.com/blackmatrix7/ios_rule_script/refs/heads/master/rule/Clash/WeChat/WeChat.list" -o rules/Domain/WeChat.list
- name: Extract DOMAIN rules from WeChat.list
run: |
# 提取 WeChat.list 中的 DOMAIN 和 DOMAIN-SUFFIX 规则
grep -Eo 'DOMAIN-SUFFIX,[^,]+' rules/Domain/WeChat.list | sed 's/DOMAIN-SUFFIX,//' > rules/Domain/WeChat-domain.list
grep -Eo 'DOMAIN,[^,]+' rules/Domain/WeChat.list | sed 's/DOMAIN,//' >> rules/Domain/WeChat-domain.list
- name: Format extracted domains as YAML
run: |
echo "payload:" > rules/Domain/WeChat.yaml
sort -u rules/Domain/WeChat-domain.list | awk '{print " - \047" $0 "\047"}' >> rules/Domain/WeChat.yaml
- name: Convert WeChat DOMAIN rules to MRS
run: |
# 使用 mihomo 转换为 MRS 格式
mihomo convert-ruleset domain yaml rules/Domain/WeChat.yaml rules/Domain/WeChat.mrs
rm -f rules/Domain/WeChat.list rules/Domain/WeChat-domain.list rules/Domain/WeChat.yaml
- name: Commit and Push Changes
run: |
git add .
git diff-index --quiet HEAD -- || (git commit -m "Updated WeChat rules (WeChat.list -> WeChat.mrs)" && git push)