Sync and Compile Google VPN Rules #390
This file contains hidden or 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 Google VPN Rules | |
| on: | |
| schedule: | |
| - cron: '0 18 * * *' # 每天北京时间02:00执行 | |
| workflow_dispatch: | |
| permissions: | |
| contents: write | |
| jobs: | |
| googlevpn_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 Google VPN Rules | |
| run: | | |
| mkdir -p rules/Domain # 确保目录存在 | |
| # 下载 Google VPN 规则文件 | |
| curl -sL "https://raw.githubusercontent.com/Lanlan13-14/Rules/refs/heads/main/rules/Domain/googleVPN.list" -o rules/Domain/googleVPN.list | |
| - name: Extract DOMAIN-SUFFIX rules from googleVPN.list | |
| run: | | |
| # 提取 googleVPN.list 中的 DOMAIN-SUFFIX 规则,并添加 *. | |
| grep -Eo 'DOMAIN-SUFFIX,[^,]+' rules/Domain/googleVPN.list | sed 's/DOMAIN-SUFFIX,//' | awk '{print "*." $0}' > rules/Domain/googleVPN-domain.list | |
| - name: Convert Google VPN Rules to YAML | |
| run: | | |
| echo "payload:" > rules/Domain/googleVPN.yaml | |
| sort -u rules/Domain/googleVPN-domain.list | awk '{print " - \047" $0 "\047"}' >> rules/Domain/googleVPN.yaml | |
| - name: Convert Google VPN Rules to MRS | |
| run: | | |
| # 使用 mihomo 转换为 MRS 格式 | |
| mihomo convert-ruleset domain yaml rules/Domain/googleVPN.yaml rules/Domain/googleVPN.mrs | |
| - name: Clean up the source files | |
| run: | | |
| # 删除中间文件,但保留 googleVPN.list 和 googleVPN.yaml | |
| rm -f rules/Domain/googleVPN-domain.list | |
| - name: Commit and Push Changes | |
| run: | | |
| git add . | |
| git diff-index --quiet HEAD -- || (git commit -m "Updated Google VPN rules (googleVPN.list -> googleVPN.mrs)" && git push) |