Generate shadowrocket rules #1611
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: Создаем файл domain_community.list | |
run: | | |
curl -sSL https://raw.githubusercontent.com/misha-tgshv/shadowrocket-configuration-file/main/community.list \ | |
| sed -E '/^[^#].*./s/^/DOMAIN-SUFFIX,/' > domain_community.list | |
sed -i "1s/^/#special\n/" domain_community.list | |
sed -i "2s/^/DOMAIN-KEYWORD,instagram\n/" domain_community.list | |
sed -i "3s/^/DOMAIN-KEYWORD,4pda\n/" domain_community.list | |
sed -i "4s/^/DOMAIN,spotify.com\n/" domain_community.list | |
- name: Создаем файл domain_antifilter.list | |
run: | | |
curl -sSL https://community.antifilter.download/list/domains.lst \ | |
| sed -E 's/^\+\./DOMAIN-SUFFIX,/; s/^[^D]/DOMAIN-SUFFIX,&/' > domain_antifilter.list | |
sed -i -E '/www|DOMAIN-SUFFIX,spotify.com/d' domain_antifilter.list | |
awk '!seen[$0]++' domain_antifilter.list | |
- name: Создаем файл domain_refilter.list | |
run: | | |
curl -sSL https://raw.githubusercontent.com/1andrevich/Re-filter-lists/refs/heads/main/community.lst \ | |
| sed -E 's/^\+\./DOMAIN-SUFFIX,/; s/^[^D]/DOMAIN-SUFFIX,&/' > domain_refilter.list | |
sed -i -E '/www|DOMAIN-SUFFIX,spotify.com/d' domain_refilter.list | |
awk '!seen[$0]++' domain_refilter.list | |
- name: Создаем файл domain_youtube.list | |
run: | | |
curl -sSL https://raw.githubusercontent.com/dsvip/Quantumult-X/dec9019816ba55897c162c3dbd3ac997ac160f09/blackmatrix7/rule/Shadowrocket/YouTube.list \ | |
| sed -n '/DOMAIN-SUFFIX,/p' > domain_youtube.list | |
sed -i "1s/^/DOMAIN-KEYWORD,youtube\n/" domain_youtube.list | |
sed -i "1s/^/DOMAIN-KEYWORD,googlevideo\n/" domain_youtube.list | |
- name: Создаем файл domain_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' > domain_discord.list | |
sed -i "1s/^/DOMAIN-KEYWORD,discord\n/" domain_discord.list | |
sed -i "1s/^/DOMAIN-KEYWORD,discordapp\n/" domain_discord.list | |
- name: Создаем файл ip_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 | |
- 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_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/release/rules/domain_community.list,PROXY | |
# Список доменов antifilter | |
RULE-SET,https://raw.githubusercontent.com/misha-tgshv/shadowrocket-configuration-file/release/rules/domain_antifilter.list,PROXY | |
# Список доменов refilter | |
RULE-SET,https://raw.githubusercontent.com/misha-tgshv/shadowrocket-configuration-file/release/rules/domain_refilter.list,PROXY | |
# Список ip-адресов refilter | |
RULE-SET,https://raw.githubusercontent.com/misha-tgshv/shadowrocket-configuration-file/release/rules/ip_refilter.list,PROXY,no-resolve | |
# Список доменов Youtube | |
RULE-SET,https://raw.githubusercontent.com/misha-tgshv/shadowrocket-configuration-file/release/rules/domain_youtube.list,PROXY | |
# Список доменов Discord | |
RULE-SET,https://raw.githubusercontent.com/misha-tgshv/shadowrocket-configuration-file/release/rules/domain_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_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 | |
conf | |
- name: Удаляем старые теги и релизы | |
uses: dev-drprasad/[email protected] | |
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 |