Generate rule-set .srs fron .json #49
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 rule-set .srs fron .json | |
on: | |
schedule: | |
- cron: '0 */72 * * *' # Every three days | |
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 | |
bash <(curl -fsSL https://sing-box.app/deb-install.sh) | |
- name: Generate srs | |
env: | |
NO_SKIP: true | |
run: | | |
sing-box rule-set compile --output /home/runner/work/sb-rule-sets/sb-rule-sets/torrent-clients.srs /home/runner/work/sb-rule-sets/sb-rule-sets/torrent-clients.json | |
sing-box rule-set compile --output /home/runner/work/sb-rule-sets/sb-rule-sets/ru-app-list.srs /home/runner/work/sb-rule-sets/sb-rule-sets/ru-app-list.json | |
sing-box rule-set compile --output /home/runner/work/sb-rule-sets/sb-rule-sets/unbanru-app-list.srs /home/runner/work/sb-rule-sets/sb-rule-sets/unbanru-app-list.json | |
- name: Generate srs no-russia-hosts | |
env: | |
NO_SKIP: true | |
run: | | |
wget -O no-russia-hosts.txt https://github.com/dartraiden/no-russia-hosts/raw/master/hosts.txt | |
sing-box rule-set convert --type adguard --output /home/runner/work/sb-rule-sets/sb-rule-sets/no-russia-hosts.srs no-russia-hosts.txt | |
sing-box rule-set decompile /home/runner/work/sb-rule-sets/sb-rule-sets/no-russia-hosts.srs --output /home/runner/work/sb-rule-sets/sb-rule-sets/no-russia-hosts.json | |
rm no-russia-hosts.txt | |
jq '.rules[0] |= with_entries(if .key == "domain" then .key = "domain_suffix" else . end)' no-russia-hosts.json > temp.json && mv temp.json no-russia-hosts.json | |
sing-box rule-set compile --output /home/runner/work/sb-rule-sets/sb-rule-sets/no-russia-hosts.srs /home/runner/work/sb-rule-sets/sb-rule-sets/no-russia-hosts.json | |
sing-box rule-set decompile /home/runner/work/sb-rule-sets/sb-rule-sets/no-russia-hosts.srs --output /home/runner/work/sb-rule-sets/sb-rule-sets/no-russia-hosts.json | |
- name: Download and Extract generate-geoip-geosite | |
run: | | |
cd /home/runner/work/sb-rule-sets/sb-rule-sets/ | |
DOWNLOAD_URL=$(curl -s https://api.github.com/repos/Dunamis4tw/generate-geoip-geosite/releases/latest | grep "generate-geoip-geosite.*linux-amd64.tar.gz" | grep "browser_download_url" | cut -d '"' -f 4) | |
ARCHIVE_NAME=${DOWNLOAD_URL##*/} | |
wget "$DOWNLOAD_URL" | |
tar -xf "$ARCHIVE_NAME" | |
rm "$ARCHIVE_NAME" | |
chmod +x generate-geoip-geosite | |
- name: Generate srs itdoginfo-allow-domains-inside-russia without .ua domain_suffix | |
env: | |
NO_SKIP: true | |
run: | | |
cd /home/runner/work/sb-rule-sets/sb-rule-sets/ | |
cat << EOF > Russia-domains-inside.json | |
[ | |
{ | |
"url": "https://github.com/itdoginfo/allow-domains/raw/main/Russia/inside-raw.lst", | |
"contentType": "DefaultList", | |
"category": "itdoginfo_inside_russia" | |
} | |
] | |
EOF | |
./generate-geoip-geosite -s Russia-domains-inside.json -i ./ -o ./ --gen-rule-set-srs | |
mv ruleset-domain-itdoginfo_inside_russia.srs itdoginfo-inside-russia.srs | |
sing-box rule-set decompile /home/runner/work/sb-rule-sets/sb-rule-sets/itdoginfo-inside-russia.srs --output /home/runner/work/sb-rule-sets/sb-rule-sets/itdoginfo-inside-russia.json | |
jq '.rules[0] |= with_entries(if .key == "domain" then .key = "domain_suffix" else . end)' itdoginfo-inside-russia.json > temp.json && mv temp.json itdoginfo-inside-russia.json | |
sing-box rule-set compile --output /home/runner/work/sb-rule-sets/sb-rule-sets/itdoginfo-inside-russia.srs /home/runner/work/sb-rule-sets/sb-rule-sets/itdoginfo-inside-russia.json | |
sing-box rule-set decompile /home/runner/work/sb-rule-sets/sb-rule-sets/itdoginfo-inside-russia.srs --output /home/runner/work/sb-rule-sets/sb-rule-sets/itdoginfo-inside-russia.json | |
- name: Generate bundle itdoginfo-inside-russia+no-russia-hosts | |
env: | |
NO_SKIP: true | |
run: | | |
jq -s '{version: .[0].version, rules: [{domain_suffix: (.[0].rules[0].domain_suffix + .[1].rules[0].domain_suffix) | unique}]}' itdoginfo-inside-russia.json no-russia-hosts.json > ru-bundle.json | |
sing-box rule-set compile --output /home/runner/work/sb-rule-sets/sb-rule-sets/ru-bundle.srs /home/runner/work/sb-rule-sets/sb-rule-sets/ru-bundle.json | |
sing-box rule-set decompile /home/runner/work/sb-rule-sets/sb-rule-sets/ru-bundle.srs --output /home/runner/work/sb-rule-sets/sb-rule-sets/ru-bundle.json | |
- name: Delete generate-geoip-geosite tool | |
run: | | |
rm -f /home/runner/work/sb-rule-sets/sb-rule-sets/generate-geoip-geosite | |
rm -f /home/runner/work/sb-rule-sets/sb-rule-sets/Russia-domains-inside.json | |
rm -f /home/runner/work/sb-rule-sets/sb-rule-sets/include-domain-itdoginfo_inside_russia.lst | |
- 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 .srs rule-sets ${{ env.DATE }}' | |
push: true | |
cwd: . | |
default_author: github_actor | |
fetch: --tags --force | |
pathspec_error_handling: ignore | |
github_token: ${{ secrets.RULESET_TOKEN }} |