Skip to content

Generate mihomo

Generate mihomo #35

Workflow file for this run

name: Generate mihomo
on:
schedule:
- cron: "30 1 * * *"
workflow_dispatch:
permissions:
contents: write
jobs:
generate_lists:
runs-on: ubuntu-latest
steps:
- name: Checkout Repository
uses: actions/checkout@v4
- name: Pull Changes
run: git pull
- name: Set up Node.js (if required)
uses: actions/setup-node@v4
with:
node-version: '20' # Adjust if needed
- name: Install Dependencies
run: |
sudo apt update
sudo apt install -y curl wget git jq
- name: Download and install Mihomo
run: |
curl -s https://api.github.com/repos/MetaCubeX/mihomo/releases \
| grep "browser_download_url.*mihomo-linux-amd64-alpha.*.deb" \
| head -n 1 \
| cut -d '"' -f 4 \
| xargs wget -q -O mihomo-linux-amd64-alpha.deb
sudo apt install --fix-missing ./mihomo-linux-amd64-alpha.deb
shell: bash
- name: Generate ru-bundle
env:
NO_SKIP: true
run: |
mkdir -p ru-bundle
wget -O ru-bundle.lst https://github.com/legiz-ru/sb-rule-sets/raw/main/ru-bundle.lst
echo "payload:" > rule.yaml && cat ru-bundle.lst | sed "s/.*/- '+.&'/" >> rule.yaml
mihomo convert-ruleset domain yaml rule.yaml rule.mrs
sed 's/^/+\./' ru-bundle.lst > rule.list
mv rule.yaml rule.mrs rule.list ru-bundle/
- name: Generate re-filter
env:
NO_SKIP: true
run: |
mkdir -p re-filter
wget -O re-filter-ip.text https://github.com/1andrevich/Re-filter-lists/raw/main/ipsum.lst
mihomo convert-ruleset ipcidr text re-filter-ip.text ip-rule.mrs
wget -O re-filter-domain.text https://github.com/1andrevich/Re-filter-lists/raw/main/domains_all.lst
mihomo convert-ruleset domain text re-filter-domain.text domain-rule.mrs
mv domain-rule.mrs ip-rule.mrs re-filter/
- name: Generate oisd
env:
NO_SKIP: true
run: |
mkdir -p oisd
wget -O oisd_big.txt https://github.com/sjhgvr/oisd/raw/main/domainswild2_big.txt
wget -O oisd_nsfw.txt https://github.com/sjhgvr/oisd/raw/main/domainswild2_nsfw.txt
wget -O oisd_nsfw_small.txt https://github.com/sjhgvr/oisd/raw/main/domainswild2_nsfw_small.txt
wget -O oisd_small.txt https://github.com/sjhgvr/oisd/raw/main/domainswild2_small.txt
mihomo convert-ruleset domain text oisd_big.txt big.mrs
mihomo convert-ruleset domain text oisd_nsfw.txt nsfw.mrs
mihomo convert-ruleset domain text oisd_nsfw_small.txt nsfw_small.mrs
mihomo convert-ruleset domain text oisd_small.txt small.mrs
mv big.mrs nsfw.mrs nsfw_small.mrs small.mrs oisd/
- name: Generate other rulesets
env:
NO_SKIP: true
run: |
mkdir -p other
wget -O torrent-websites.txt https://github.com/sakib-m/Pi-hole-Torrent-Blocklist/raw/main/all-torrent-websites.txt
wget -O torrent-trackers.txt https://github.com/sakib-m/Pi-hole-Torrent-Blocklist/raw/main/all-torrent-trackres.txt
wget -O torrent-clients.json https://github.com/legiz-ru/sb-rule-sets/raw/main/torrent-clients.json
mihomo convert-ruleset domain text torrent-websites.txt torrent-websites.mrs
mihomo convert-ruleset domain text torrent-trackers.txt torrent-trackers.mrs
echo "payload:" > torrent-clients.yaml && jq -r '.rules[] | .rules[] | .process_name[], .package_name[]' torrent-clients.json | awk '{print " - PROCESS-NAME," $0}' >> torrent-clients.yaml
mv torrent-websites.mrs torrent-trackers.mrs torrent-clients.yaml other/
- name: Delete temp file
run: |
rm ru-bundle.lst | rm re-filter-ip.text | rm re-filter-domain.text | rm mihomo-linux-amd64-alpha.deb
rm oisd_big.txt | rm oisd_nsfw.txt | rm oisd_nsfw_small.txt | rm oisd_small.txt
rm torrent-websites.txt | rm torrent-trackers.txt | rm torrent-clients.json
- name: Get current date
id: date
run: |
echo "DATE=$(TZ=Europe/Moscow date +'%Y-%m-%dT%H:%M:%S')" >> $GITHUB_ENV
- name: Commit and Push Changes
uses: EndBug/add-and-commit@v9
with:
author_name: GitHub Action
author_email: [email protected]
message: 'Generating .mrs rule-sets ${{ env.DATE }}'
push: true
cwd: .
default_author: github_actor
fetch: --tags --force
pathspec_error_handling: ignore
github_token: ${{ secrets.RULESET_TOKEN }}