Skip to content

Sync and Compile Google Rules #118

Sync and Compile Google Rules

Sync and Compile Google Rules #118

Workflow file for this run

name: Sync and Compile Google Rules
on:
schedule:
- cron: '0 18 * * *' # 例如每天18点触发
workflow_dispatch:
permissions:
contents: write
jobs:
google_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 and Merge Google Rules
run: |
mkdir -p rules/Domain # 确保目录存在
# 下载 Google 规则文件
curl -sL "https://raw.githubusercontent.com/MetaCubeX/meta-rules-dat/refs/heads/meta/geo/geosite/google-play.list" -o rules/Domain/google-play.list
curl -sL "https://raw.githubusercontent.com/MetaCubeX/meta-rules-dat/meta/geo/geosite/google.list" -o rules/Domain/google.list
# 合并去重
cat rules/Domain/google-play.list rules/Domain/google.list | grep -v '^#' | sort -u > rules/Domain/merged_google.list
- name: Convert merged Google rules to YAML
run: |
echo "payload:" > rules/Domain/google.yaml
while IFS= read -r line; do
if [[ -n "$line" ]]; then
echo " - $line" >> rules/Domain/google.yaml
fi
done < rules/Domain/merged_google.list
- name: Convert Google Rules to MRS
run: |
mihomo convert-ruleset domain yaml rules/Domain/google.yaml rules/Domain/google.mrs
rm -f rules/Domain/google-play.list rules/Domain/google.list rules/Domain/merged_google.list
- name: Commit and Push Changes
run: |
git add .
git diff-index --quiet HEAD -- || (git commit -m "Updated Google rules (merged google.list -> google.mrs)" && git push)