Skip to content

Commit 748de30

Browse files
authored
Update update.yml
1 parent f7fc17d commit 748de30

1 file changed

Lines changed: 61 additions & 27 deletions

File tree

.github/workflows/update.yml

Lines changed: 61 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ name: Build SingBox Config
22

33
on:
44
schedule:
5-
- cron: "0 */1 * * *"
5+
- cron: "0 */2 * * *"
66
workflow_dispatch:
77

88
jobs:
@@ -13,36 +13,70 @@ jobs:
1313
- name: Checkout repo
1414
uses: actions/checkout@v4
1515

16-
- name: Build config via API
16+
- name: Build configs via API
1717
run: |
18+
1819
SUB=$(curl -s "https://raw.githack.com/igareck/vpn-configs-for-russia/main/Vless-Reality-White-Lists-Rus-Mobile.txt" | tr -d '\r')
19-
CLEAN=$(echo "$SUB" | grep -E '^(vless|vmess|trojan)://' | grep -Ei 'russia' | head -n 5)
20-
CLEAN10=$(echo "$SUB" | grep -E '^(vless|vmess|trojan)://' | grep -Ei 'russia' | head -n 10)
21-
22-
if [ -z "$CLEAN" ]; then
23-
echo "ERROR: Нет ключей в списке"
24-
exit 1
25-
fi
26-
27-
jq -n --arg input "$CLEAN" '{
28-
core: "singbox",
29-
input: $input,
30-
options: { addTun: true, addSocks: true, genClashSecret: false, useExtended: false }
31-
}' | curl -sS -X POST "https://api.web2core.workers.dev/" -H "Content-Type: application/json" --data-binary @- > config.json
32-
33-
jq -n --arg input "$CLEAN10" '{
34-
core: "singbox",
35-
input: $input,
36-
options: { addTun: true, addSocks: true, genClashSecret: false, useExtended: false }
37-
}' | curl -sS -X POST "https://api.web2core.workers.dev/" -H "Content-Type: application/json" --data-binary @- > config10.json
38-
39-
40-
- name: Commit config
20+
21+
ALL=$(echo "$SUB" | grep -E '^(vless|vmess|trojan)://')
22+
23+
RUSSIA=$(echo "$ALL" | grep -Ei 'russia' || true)
24+
25+
NON_RUSSIA=$(echo "$ALL" | grep -Evi 'russia' | shuf || true)
26+
27+
build_config () {
28+
29+
TARGET=$1
30+
RU_TARGET=$2
31+
OUTPUT=$3
32+
33+
RU_SELECTED=$(echo "$RUSSIA" | head -n "$RU_TARGET")
34+
35+
RU_COUNT=$(echo "$RU_SELECTED" | grep -c . || true)
36+
37+
NEED=$((TARGET - RU_COUNT))
38+
39+
NONRU_SELECTED=$(echo "$NON_RUSSIA" | head -n "$NEED")
40+
41+
FINAL=$(printf "%s\n%s\n" "$RU_SELECTED" "$NONRU_SELECTED" | grep .)
42+
43+
COUNT=$(echo "$FINAL" | grep -c . || true)
44+
45+
if [ "$COUNT" -eq 0 ]; then
46+
echo "ERROR: Нет доступных ключей"
47+
exit 1
48+
fi
49+
50+
echo "Building $OUTPUT with $COUNT nodes..."
51+
52+
jq -n --arg input "$FINAL" '{
53+
core: "singbox",
54+
input: $input,
55+
options: {
56+
addTun: true,
57+
addSocks: true,
58+
genClashSecret: false,
59+
useExtended: false
60+
}
61+
}' \
62+
| curl -sS -X POST "https://api.web2core.workers.dev/" \
63+
-H "Content-Type: application/json" \
64+
--data-binary @- \
65+
> "$OUTPUT"
66+
}
67+
68+
# config.json → target 5, prefer 3 RU
69+
build_config 5 3 config.json
70+
71+
# config10.json → target 10, prefer 6 RU
72+
build_config 10 6 config10.json
73+
74+
75+
- name: Commit configs
4176
run: |
4277
git config user.name "github-actions"
4378
git config user.email "actions@github.com"
4479
45-
git add config.json
46-
git add config10.json
47-
git commit -m "auto update config" || exit 0
80+
git add config.json config10.json
81+
git commit -m "auto update configs" || exit 0
4882
git push

0 commit comments

Comments
 (0)