Merge rules #223
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: Merge rules | |
on: | |
schedule: | |
- cron: '0 0 * * *' | |
workflow_dispatch: | |
jobs: | |
merge-and-clean: | |
runs-on: ubuntu-latest | |
env: | |
TZ: 'Asia/Shanghai' | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
- name: Install mihomo | |
run: | | |
version=$(curl -skL https://github.com/MetaCubeX/mihomo/releases/download/Prerelease-Alpha/version.txt) | |
curl -skLo mihomo.deb https://github.com/MetaCubeX/mihomo/releases/download/Prerelease-Alpha/mihomo-linux-amd64-$version.deb | |
sudo dpkg -i mihomo.deb | |
- name: Convert AdRules and hagezi | |
run: | | |
curl https://adrules.top/adrules_domainset.txt -o adrules_domainset.txt | |
curl https://cdn.jsdelivr.net/gh/hagezi/dns-blocklists@latest/wildcard/multi.txt -o multi.txt | |
cat adrules_domainset.txt multi.txt | sed '/^#/d' | sort | uniq > combined.txt | |
awk '/^\+\./ {gsub(/^\+/, "*"); print}' combined.txt > exclude_list.txt | |
awk 'NR==FNR {exclude[$0]; next} !($0 in exclude)' exclude_list.txt combined.txt | sort | uniq > ADs_merged_temp.txt | |
mihomo convert-ruleset domain text ADs_merged_temp.txt ADs_merged.mrs | |
- name: Convert AWAvenue rules | |
run: | | |
wget https://raw.githubusercontent.com/TG-Twilight/AWAvenue-Ads-Rule/main/Filters/AWAvenue-Ads-Rule-Clash.yaml | |
mihomo convert-ruleset domain yaml AWAvenue-Ads-Rule-Clash.yaml ADs_AWAvenue.mrs | |
- name: more mrs | |
run: | | |
wget https://ruleset.skk.moe/Clash/domainset/speedtest.txt | |
mihomo convert-ruleset domain text speedtest.txt speedtest.mrs | |
- name: Commit and push changes | |
run: | | |
mv *.mrs rules/ | |
CURRENT_TIME=$(date +"%Y-%m-%d %H:%M") | |
git config user.name 'github-actions[bot]' | |
git config user.email 'github-actions[bot]@users.noreply.github.com' | |
git checkout --orphan mihomo | |
git rm -rf . | |
git add rules/* | |
git commit -m "Auto Update $CURRENT_TIME" | |
git push -f origin mihomo | |
- name: Delete workflow runs | |
uses: Mattraks/delete-workflow-runs@main | |
with: | |
token: ${{ secrets.GITHUB_TOKEN }} | |
repository: ${{ github.repository }} | |
retain_days: 0 | |
keep_minimum_runs: 2 |