Sync and Compile Emby IP Rules #12
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 Emby IP Rules | |
on: | |
schedule: | |
- cron: '0 18 * * *' # 北京时间 02:00 执行 | |
workflow_dispatch: | |
permissions: | |
contents: write | |
jobs: | |
emby_ip_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 Emby IP Rules | |
run: | | |
mkdir -p rules/IP # 确保目录存在 | |
# 下载 Emby IP 规则文件 | |
curl -sL "https://raw.githubusercontent.com/Lanlan13-14/Rules/refs/heads/main/rules/IP/emby_ip.list" -o rules/IP/emby_ip.list | |
curl -sL "https://raw.githubusercontent.com/666OS/YYDS/refs/heads/main/mihomo/rules/emby.list" -o rules/IP/emby.list | |
- name: Convert Emby IP Rules to YAML | |
run: | | |
# 提取 IP-CIDR 规则中的 IP 地址部分 | |
echo "payload:" > rules/IP/emby_ip_combined.yaml | |
cat rules/IP/emby_ip.list rules/IP/emby.list | grep '^IP-CIDR' | awk -F, '{print " - "$2}' >> rules/IP/emby_ip_combined.yaml | |
- name: Convert Emby IP Rules to MRS | |
run: | | |
# 使用 mihomo 转换为 MRS 格式 | |
mihomo convert-ruleset ipcidr yaml rules/IP/emby_ip_combined.yaml rules/IP/emby-ip.mrs | |
# 清理临时文件,但保留 emby_ip.list | |
rm -f rules/IP/emby.list rules/IP/emby_ip_combined.yaml | |
- name: Commit and Push Changes | |
run: | | |
git add . | |
git diff-index --quiet HEAD -- || (git commit -m "Updated Emby IP rules -> emby-ip.mrs" && git push) |