Update run.yml #1701
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 shadowrocket rules | |
on: | |
workflow_dispatch: | |
schedule: | |
- cron: "0 0 * * *" | |
push: | |
branches: | |
- main | |
jobs: | |
build_rules_list: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Создаем файл domains_community.list | |
run: | | |
curl -s https://raw.githubusercontent.com/misha-tgshv/shadowrocket-configuration-file/main/community.list \ | |
| awk ' | |
NR==2 {print "DOMAIN-KEYWORD," $0; next} | |
NR==3 {print "DOMAIN-KEYWORD," $0; next} | |
NR==4 {print "DOMAIN," $0; next} | |
!/^#/ && NF>0 {print "DOMAIN-SUFFIX," $0} | |
/^#/ || NF==0 {print $0} # Добавляем это условие для пустых строк и строк с # | |
' > domains_community.list | |
- name: Создаем файл domains_antifilter.list | |
run: | | |
curl -sSL https://community.antifilter.download/list/domains.lst \ | |
| sed -E 's/^\+\./DOMAIN-SUFFIX,/; s/^[^D]/DOMAIN-SUFFIX,&/' \ | |
| sed '/www|spotify.com/d' \ | |
| awk '!seen[$0]++' > temp_list.txt \ | |
&& echo "# Количество доменов: $(wc -l < temp_list.txt)" > domains_antifilter.list \ | |
&& cat temp_list.txt >> domains_antifilter.list \ | |
&& rm temp_list.txt | |
- name: Создаем файл ips_antifilter.list | |
run: | | |
curl -s https://community.antifilter.download/list/community.lst \ | |
| sed 's/^/IP-CIDR,/g' \ | |
| sort -u > temp_aips.txt \ | |
&& echo "# Количество IP-адресов: $(wc -l < temp_aips.txt)" > ips_antifilter.list \ | |
&& cat temp_aips.txt >> ips_antifilter.list \ | |
&& rm temp_aips.txt | |
- name: Создаем файл domains_refilter.list | |
run: | | |
curl -s https://raw.githubusercontent.com/1andrevich/Re-filter-lists/main/community.lst > temp.txt && | |
curl -s https://raw.githubusercontent.com/1andrevich/Re-filter-lists/main/domains_all.lst >> temp.txt && | |
grep -v "mega555" temp.txt > temp2.txt && | |
grep -v "spotify.com" temp2.txt > temp3.txt && | |
rm temp.txt temp2.txt | |
echo "# NAME: domains_refilter.list" > domains_refilter.list && | |
echo "# AUTHOR: misha-tgshv" >> domains_refilter.list && | |
echo "# REPO: https://github.com/misha-tgshv/shadowrocket-configuration-file" >> domains_refilter.list && | |
echo "# UPDATED: $(TZ='Europe/Moscow' date '+%Y-%m-%d %H:%M:%S') MSK" >> domains_refilter.list && | |
echo "# SOURCE: https://github.com/1andrevich/Re-filter-lists" >> domains_refilter.list | |
sed 's/^/DOMAIN-SUFFIX,/g' temp3.txt | tee domaintmp | |
wc -l < domaintmp | awk '{print "# TOTAL:", $1}' >> domains_refilter.list | |
cat domaintmp >> domains_refilter.list && rm domaintmp temp3.txt | |
- name: Создаем файл domains_youtube.list | |
run: | | |
curl -sSL https://raw.githubusercontent.com/dsvip/Quantumult-X/dec9019816ba55897c162c3dbd3ac997ac160f09/blackmatrix7/rule/Shadowrocket/YouTube.list \ | |
| sed -n '/DOMAIN-SUFFIX,/p' > domains_youtube.list | |
sed -i "1s/^/DOMAIN-KEYWORD,youtube\n/" domains_youtube.list | |
sed -i "1s/^/DOMAIN-KEYWORD,googlevideo\n/" domains_youtube.list | |
- name: Создаем файл domains_discord.list | |
run: | | |
curl -sSL https://raw.githubusercontent.com/blackmatrix7/ios_rule_script/refs/heads/master/rule/Shadowrocket/Discord/Discord.list \ | |
| sed -n '/DOMAIN-SUFFIX,/p' > domains_discord.list | |
sed -i "1s/^/DOMAIN-KEYWORD,discord\n/" domains_discord.list | |
sed -i "1s/^/DOMAIN-KEYWORD,discordapp\n/" domains_discord.list | |
- name: Создаем файл ips_refilter.list | |
run: | | |
# curl -sSL https://raw.githubusercontent.com/1andrevich/Re-filter-lists/refs/heads/main/ipsum.lst | sed 's/^/IP-CIDR,/' > ip_refilter.list | |
curl -s https://raw.githubusercontent.com/1andrevich/Re-filter-lists/refs/heads/main/community_ips.lst > ips1.txt \ | |
&& curl -s https://raw.githubusercontent.com/1andrevich/Re-filter-lists/refs/heads/main/discord_ips.lst >> ips1.txt \ | |
&& curl -s https://raw.githubusercontent.com/1andrevich/Re-filter-lists/refs/heads/main/ipsum.lst >> ips1.txt \ | |
&& sed 's/^/IP-CIDR,/g' ips1.txt | sort -u > temp_ips.list \ | |
&& echo "# Количество IP-адресов: $(wc -l < temp_ips.list)" > ips_refilter.list \ | |
&& cat temp_ips.list >> ips_refilter.list \ | |
&& rm ips1.txt temp_ips.list | |
- name: Создаем файл domains_banking.list | |
run: | | |
# Скачиваем HTML-страницу и извлекаем ссылки | |
curl -s https://www.cbr.ru/banking_sector/credit/cowebsites/ | \ | |
grep -oP 'href="\K[^"]+' | \ | |
grep '^http' | \ | |
# Удаляем нежелательные строки | |
sed -E '/(t\.me|vk\.com|ok\.ru|telegram|dzen|twitter|youtube|zen\.yandex\.ru|rutube\.ru)/d' | \ | |
# Удаляем http:// или https:// в начале строки | |
sed 's/^https\?:\/\///' | \ | |
# Добавляем DOMAIN-SUFFIX в начало строки | |
sed 's/^/DOMAIN-SUFFIX,/' > domains_banking.list | |
- name: Перемещаем файлы в директорю rules | |
run: | | |
mkdir -p rules.d | |
cp *.list ./rules.d/ | |
- name: Загружаем список файлов rules через artifact | |
uses: actions/upload-artifact@v4 | |
with: | |
name: rules | |
path: ./rules.d/ | |
build_scripts_js: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Создаем файл rewrite.youtube.response.preview.js | |
run: | | |
curl -sSL "https://raw.githubusercontent.com/Maasea/sgmodule/master/Script/Youtube/dist/youtube.response.preview.js" > temp.txt && sed 's/;e!/;e/g' temp.txt > rewrite.youtube.response.preview.js && rm temp.txt | |
- name: Перемещаем файлы в директорю scripts | |
run: | | |
mkdir -p scripts.d | |
cp *.js ./scripts.d/ | |
- name: Загружаем список файлов sctipts через artifact | |
uses: actions/upload-artifact@v4 | |
with: | |
name: scripts | |
path: ./scripts.d/ | |
build_YT_premium_v1_module: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Создаем файл YT-Premium-V1-RU.module | |
run: | | |
curl -sSL https://raw.githubusercontent.com/YanbingJiang/Shadowrocket_diy_rules/9b86dfbca387fa69e8d4b02d3f8ba01250eaad16/Modules/YT-Premium-V1.module \ | |
| sed -E 's/captionLang:zh-Hans/captionLang:off/g; s/lyricLang:zh-Hans/lyricLang:ru-ru/g' > YT-Premium-V1-RU.module | |
sed -i 's/https:\/\/raw\.githubusercontent\.com\/Maasea\/sgmodule\/master\/Script\/Youtube\/dist\/youtube\.response\.preview\.js/https:\/\/raw\.githubusercontent\.com\/misha-tgshv\/shadowrocket-configuration-file\/refs\/heads\/release\/scripts\/rewrite\.youtube\.response\.preview\.js/g' YT-Premium-V1-RU.module | |
- name: Перемещаем файлы в директорю modules | |
run: | | |
mkdir -p modules.d | |
cp *.module ./modules.d/ | |
- name: Загружаем список файлов modules через artifact | |
uses: actions/upload-artifact@v4 | |
with: | |
name: modules | |
path: ./modules.d/ | |
build_Shadowrocket_conf_file: | |
runs-on: ubuntu-latest | |
needs: build_rules_list | |
steps: | |
- name: Создаем папку | |
run: | | |
mkdir -p conf.d | |
- name: Получаем шаблон файла General | |
uses: actions/checkout@v4 | |
with: | |
repository: ${{ github.repository }} | |
ref: 'Custom' | |
token: ${{ secrets.ACCESS_TOKEN }} | |
sparse-checkout: | | |
General.txt | |
sparse-checkout-cone-mode: false | |
path: conf.d | |
- name: Добавляем списки правил в конец файла General | |
run: | | |
cat <<EOF >> ./conf.d/General.txt | |
# Выборочные правила маршрутизации | |
[Rule] | |
# Список доменов телеграм-чата «Про Shadowrocket на русском» | |
RULE-SET,https://raw.githubusercontent.com/misha-tgshv/shadowrocket-configuration-file/refs/heads/release/rules/domains_community.list,PROXY | |
# Список доменов refilter | |
RULE-SET,https://raw.githubusercontent.com/misha-tgshv/shadowrocket-configuration-file/refs/heads/release/rules/domains_refilter.list,PROXY | |
# Список ip-адресов refilter | |
RULE-SET,https://raw.githubusercontent.com/misha-tgshv/shadowrocket-configuration-file/refs/heads/release/rules/ips_refilter.list,PROXY,no-resolve | |
# Список доменов Discord | |
RULE-SET,https://raw.githubusercontent.com/misha-tgshv/shadowrocket-configuration-file/refs/heads/release/rules/domains_discord.list,PROXY | |
# Список портов Discord | |
RULE-SET,https://raw.githubusercontent.com/helmiau/clashrules/refs/heads/main/shadowrocket/Game_Discord_Ports.list,PROXY | |
# Финальное правило маршрутизации | |
FINAL,DIRECT | |
EOF | |
# - name: Generate HTTPS decrypted configuration file | |
# run: | | |
# sed -i 's/hostname = /hostname = *instagram.com,/' MITM.txt | |
# cp MITM.txt ./conf.d | |
- name: Создаем конфиг sr_ru_public_lists.conf | |
run: | | |
cat ./conf.d/*.txt > ./conf.d/sr_ru_public_lists.conf | |
sed -i "1s/^/# @misha-tgshv, built on $(TZ="Asia/Novokuznetsk" date)\n/" ./conf.d/sr_ru_public_lists.conf | |
- name: Загружаем artifact | |
uses: actions/upload-artifact@v4 | |
with: | |
name: conf | |
path: ./conf.d/sr_ru_public_lists.conf | |
retention-days: 1 | |
publish: | |
runs-on: ubuntu-latest | |
needs: [build_rules_list,build_scripts_js,build_YT_premium_v1_module,build_Shadowrocket_conf_file] | |
steps: | |
- name: Настраиваем переменные | |
run: | | |
echo "RELEASE_NAME=Built on $(TZ="Asia/Novokuznetsk" date +%Y%m%d%H%M)" >> $GITHUB_ENV | |
echo "TAG_NAME=$(TZ="Asia/Novokuznetsk" date +%Y%m%d%H%M)" >> $GITHUB_ENV | |
mkdir -p rules | |
- name: Скачиваем artifact | |
uses: actions/download-artifact@v4 | |
with: | |
path: ./rules | |
- name: Публикуем и загружаем artifacts | |
uses: softprops/action-gh-release@v2 | |
with: | |
name: ${{ env.RELEASE_NAME }} | |
tag_name: ${{ env.TAG_NAME }} | |
draft: false | |
prerelease: false | |
files: | | |
./rules/* | |
env: | |
GITHUB_TOKEN: ${{ secrets.ACCESS_TOKEN }} | |
- name: Загружаем artifact в ветку "release" | |
run: | | |
cd rules || exit 1 | |
git init | |
git config --local user.name ${{ secrets.USER_NAME }} | |
git config --local user.email ${{ secrets.USER_EMAIL }} | |
git checkout -b release | |
git add . | |
git commit -m "${{ env.RELEASE_NAME }}" | |
git remote add origin "https://${{ github.actor }}:${{ secrets.ACCESS_TOKEN }}@github.com/${{ github.repository }}" | |
git push -f origin release | |
# git push --delete origin $( git ls-remote --tags origin | awk '{print $2}' | grep -vE "$(echo -e ${TAG_NAME})") | |
- name: Очищаем jsdelivr CDN | |
run: | | |
cd rules || exit 1 | |
for file in $(ls); do | |
curl -i "https://purge.jsdelivr.net/gh/${{ github.repository }}@release/${file}" | |
done | |
Delete_Historical_Data: | |
runs-on: ubuntu-latest | |
needs: publish | |
steps: | |
- name: Delete old artifacts | |
uses: geekyeggo/delete-artifact@v5 | |
with: | |
name: | | |
rules | |
modules | |
conf | |
- name: Удаляем старые теги и релизы | |
uses: dev-drprasad/delete-older-releases@v0.3.4 | |
with: | |
keep_latest: 3 | |
delete_expired_data: 7 | |
delete_tags: true | |
env: | |
GITHUB_TOKEN: ${{ secrets.ACCESS_TOKEN }} | |
- name: Удаляем старый workflow | |
uses: Mattraks/delete-workflow-runs@v2 | |
with: | |
token: ${{ secrets.ACCESS_TOKEN }} | |
repository: ${{ github.repository }} | |
retain_days: 7 | |
keep_minimum_runs: 3 |