Generate mihomo #44
Workflow file for this run
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: 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 ruleset-domain-refilter_domains.json https://github.com/1andrevich/Re-filter-lists/releases/latest/download/ruleset-domain-refilter_domains.json | |
jq -r '.rules[0].domain as $domain | .rules[0].domainsuffix as $domainsuffix | ($domain + $domainsuffix | unique) | map(select(.) | (if $domainsuffix and length > 0 then (if index(($domainsuffix // [])[0]) != null then "+." + . else . end) else . end)) | .[]' ruleset-domain-refilterdomains.json > domain-rule.list | |
mihomo convert-ruleset domain text domain-rule.list domain-rule.mrs | |
mv domain-rule.mrs domain-rule.list 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 ruleset-domain-refilter_domains.json | 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 }} |