-
Notifications
You must be signed in to change notification settings - Fork 2
135 lines (117 loc) ยท 5.22 KB
/
run.yml
File metadata and controls
135 lines (117 loc) ยท 5.22 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
name: Generate RULE-SET for Subconverter External Config
on:
workflow_dispatch:
schedule:
- cron: "30 22 * * *"
push:
branches:
- main
paths-ignore:
- "**/README.md"
permissions:
contents: write
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Set variables
run: |
echo "RELEASE_NAME=Released on $(date +%Y%m%d%H%M)" >> $GITHUB_ENV
echo "TAG_NAME=$(date +%Y%m%d%H%M)" >> $GITHUB_ENV
declare -A env_names=(
["icloud"]="https://raw.githubusercontent.com/Loyalsoldier/domain-list-custom/release/icloud.txt"
["reject"]="https://raw.githubusercontent.com/Loyalsoldier/v2ray-rules-dat/release/reject-list.txt"
["proxy"]="https://raw.githubusercontent.com/Loyalsoldier/v2ray-rules-dat/release/proxy-list.txt"
["direct"]="https://raw.githubusercontent.com/Loyalsoldier/v2ray-rules-dat/release/direct-list.txt"
["gfw"]="https://raw.githubusercontent.com/Loyalsoldier/v2ray-rules-dat/release/gfw.txt"
["cn_cidr"]="https://raw.githubusercontent.com/Loyalsoldier/geoip/release/text/cn.txt"
["lan_cidr"]="https://raw.githubusercontent.com/Loyalsoldier/geoip/release/text/private.txt"
["chat"]="https://raw.githubusercontent.com/gitduk/clash-rules/main/custom/chat.txt"
["openai"]="https://raw.githubusercontent.com/ACL4SSR/ACL4SSR/master/Clash/Ruleset/OpenAi.list"
)
for env_name in "${!env_names[@]}"; do
env_value="${env_names[$env_name]}"
echo "$env_name=$env_value" >> $GITHUB_ENV
done
shell: bash
- name: Checkout the "hidden" branch
uses: actions/checkout@v3
with:
ref: hidden
- name: Generate txt file
run: |
generate_file () {
if [[ $# -eq 3 ]]; then
echo "# ${1}: ${2}"
eval "curl -sSL ${2} | grep -Ev "^#" | $3"
else
eval "curl -sSL ${1} | grep -Ev "^#" | $2"
fi
}
# icloud
generate_file "iCloud ๅๅๅ่กจ" ${icloud} \
"grep -E '^full:' | awk -F ':' '{printf \"DOMAIN,%s\\n\", \$2}'" | tee icloud.txt >> direct-uniq.txt
generate_file ${icloud} \
"grep -E '^domain:' | awk -F ':' '{printf \"DOMAIN-SUFFIX,%s\\n\", \$2}'" |tee -a icloud.txt >> direct-uniq.txt
# reject
generate_file "ๅนฟๅๅๅๅ่กจ" ${reject} \
"sed 's/^/DOMAIN-SUFFIX,/'" | tee reject.txt >> reject-uniq.txt
# proxy
generate_file "ไปฃ็ๅๅๅ่กจ" ${proxy} \
"grep -E '^full:' | sed 's/^full:/DOMAIN,/'" | tee proxy.txt >> proxy-uniq.txt
generate_file ${proxy} \
"grep -Ev '^(full|regexp):' | sed 's/^/DOMAIN-SUFFIX,/'" | tee -a proxy.txt >> proxy-uniq.txt
# direct
generate_file "็ด่ฟๅๅๅ่กจ" ${direct} \
"grep -E '^full:' | sed 's/^full:/DOMAIN,/'" | tee direct.txt >> direct-uniq.txt
generate_file ${direct} \
"grep -Ev '^(full|regexp):' | sed 's/^/DOMAIN-SUFFIX,/'" | tee -a direct.txt >> direct-uniq.txt
# gfw
generate_file "gfw ๅๅๅ่กจ" ${gfw} \
"sed 's/^/DOMAIN-SUFFIX,/'" | tee gfw.txt >> proxy-uniq.txt
# cn_cidr
generate_file "ไธญๅฝๅคง้ IP ๅฐๅๅ่กจ" ${cn_cidr} \
"sed 's/^/IP-CIDR,/; s/\$/,no-resolve/'" | tee cn_cidr.txt >> direct-uniq.txt
# lan_cidr
generate_file "ๅฑๅ็ฝ IP ๅไฟ็ IP ๅฐๅๅ่กจ" ${lan_cidr} \
"sed 's/^/IP-CIDR,/; s/\$/,no-resolve/'" | tee lan_cidr.txt >> direct-uniq.txt
# chat
generate_file "็ๆๅผ AI ๅๅๅ่กจ" ${chat} "cat" | tee chat.txt >> proxy-uniq.txt
# openai
generate_file "openai ๅๅๅ่กจ" ${openai} "cat" | tee openai.txt >> proxy-uniq.txt
# sort and uniq
sort -u direct-uniq.txt -o direct-uniq.txt
sort -u reject-uniq.txt -o reject-uniq.txt
sort -u proxy-uniq.txt -o proxy-uniq.txt
- name: Move files to publish directory
run: |
mkdir -p publish
mv *.txt ./publish/
- name: Release and upload assets
uses: softprops/action-gh-release@v1
with:
name: ${{ env.RELEASE_NAME }}
tag_name: ${{ env.TAG_NAME }}
draft: false
prerelease: false
files: |
./publish/*
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Git push assets to "release" branch
run: |
cd publish || exit 1
git init
git config --local user.name "github-actions[bot]"
git config --local user.email "41898282+github-actions[bot]@users.noreply.github.com"
git checkout -b release
git add .
git commit -m "${{ env.RELEASE_NAME }}"
git remote add origin "https://${{ github.actor }}:${{ secrets.GITHUB_TOKEN }}@github.com/${{ github.repository }}"
git push -f origin release
- name: Purge jsdelivr CDN
run: |
cd publish || exit 1
for file in $(ls); do
curl -i "https://purge.jsdelivr.net/gh/${{ github.repository }}@release/${file}"
done