Skip to content

Update Ruleset

Update Ruleset #17

Workflow file for this run

name: Update Ruleset
on:
workflow_dispatch:
# push:
# branches:
# - "Her"
# paths-ignore:
# - "LICENSE"
# - "*.md"
# - "**/*.md"
# - ".*"
# - "node_modules"
schedule:
- cron: 0 */24 * * *
jobs:
Update:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest]
node-version: [20]
steps:
- name: Fetch repository
uses: actions/checkout@v6
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v6
with:
node-version: ${{ matrix.node-version }}
- name: Cache node modules
uses: actions/cache@v5
with:
path: node_modules
key: ${{ runner.OS }}-build-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.OS }}-build-${{ env.cache-name }}-
${{ runner.OS }}-build-
${{ runner.OS }}-
- name: yarn install, update
run: |
yarn install
yarn update-adrules
- name: Merge and Rules and remove duplicates
run: |
awk '
FNR==NR {
gsub(/^[[:space:]]+|[[:space:]]+$/, "", $0)
if ($0 == "" || $0 ~ /^#/) next
key = $0
sub(/^\./, "", key)
bypass[key] = 1
next
}
/\*/ || /^$/ { next }
{
line = $0
key = line
sub(/^\./, "", key)
if (!(key in bypass) && !seen[line]++) {
print line
}
}
' RuleSet/AdRules/Bypass.list RuleSet/AdRules/*.list > RuleSet/AdRule.list
- name: Update Static.list, Download.list, DomesticIP.list and AdIPRule.list
run: |
curl -sL "https://ruleset.skk.moe/List/domainset/cdn.conf" | sed '/#/d; /skk\.moe/d; /^$/d' > RuleSet/Static.list
curl -sL "https://ruleset.skk.moe/List/domainset/download.conf" | sed '/#/d; /skk\.moe/d; /^$/d' > RuleSet/Download.list
curl -sL "https://ruleset.skk.moe/List/ip/china_ip.conf" "https://ruleset.skk.moe/List/ip/china_ip_ipv6.conf" | sed '/#/d; /skk\.moe/d; /^$/d' > RuleSet/DomesticIP.list
curl -sL "https://ruleset.skk.moe/List/ip/reject.conf" | sed '/#/d; /skk\.moe/d; /^$/d' > RuleSet/AdIPRule.list
- name: Update Global.list
run: |
tmp_dir="$(mktemp -d)"
trap 'rm -rf "$tmp_dir"' EXIT
curl -fsSL "https://ruleset.skk.moe/List/non_ip/global.conf" -o "$tmp_dir/global.conf"
cat RuleSet/Global.list "$tmp_dir/global.conf" \
| sed 's/\r$//' \
| awk '
{
line = $0
sub(/^[[:space:]]+/, "", line)
sub(/[[:space:]]+$/, "", line)
if (line == "" || line ~ /^#/ || tolower(line) ~ /skk\.moe/) next
print line
}
' \
| LC_ALL=C sort -u > "$tmp_dir/merged.txt"
grep -E '^IP-CIDR6?,' "$tmp_dir/merged.txt" | LC_ALL=C sort -u > "$tmp_dir/ip.txt" || true
grep -Ev '^IP-CIDR6?,' "$tmp_dir/merged.txt" | LC_ALL=C sort -u > "$tmp_dir/non_ip.txt" || true
cat "$tmp_dir/non_ip.txt" "$tmp_dir/ip.txt" > RuleSet/Global.list
- name: Import GPG key
id: import_gpg
uses: crazy-max/ghaction-import-gpg@v7
with:
gpg_private_key: ${{ secrets.GPG_PRIVATE_KEY }}
passphrase: ${{ secrets.PASSPHRASE }}
git_user_signingkey: true
git_commit_gpgsign: true
- name: commit, push
uses: EndBug/add-and-commit@v10
with:
add: "-A"
author_name: 春夏
author_email: git@aapls.com
message: "Update Ruleset"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}