Generate v2ray routing rules #347
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 v2ray routing rules | |
on: | |
workflow_dispatch: | |
schedule: | |
- cron: "0 1 * * *" | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout ru-block-v2ray-rules repository | |
uses: actions/checkout@v4 | |
- name: Checkout v2ray-geosite repository | |
uses: actions/checkout@v4 | |
with: | |
repository: Nidelon/v2ray-geosite | |
path: v2ray-geosite | |
- name: Setup Go | |
uses: actions/setup-go@v4 | |
with: | |
go-version: '1.21' | |
cache-dependency-path: v2ray-geosite/go.sum | |
- name: Set ENV variables | |
run: | | |
echo "RELEASE_NAME=$(date +%Y%m%d%H%M)" >> $GITHUB_ENV | |
echo "TAG_NAME=$(date +%Y%m%d%H%M)" >> $GITHUB_ENV | |
echo "RELEASE_DATE=$(date +'%F %T %Z')" >> $GITHUB_ENV | |
- name: Create release directory | |
run: mkdir release | |
- name: Get block IP list | |
run: curl -sSL https://antifilter.download/list/ip.lst -o ip-block-list.txt | |
- name: Get block URL list | |
run: | | |
curl -sSL https://antifilter.download/list/domains.lst -o ru-block.txt | |
echo "RU_BLOCK=$(wc -l < ru-block.txt)" >> $GITHUB_ENV | |
mv ru-block.txt release | |
- name: Generate geoip.dat and Country.mmdb files | |
run: | | |
go install -v github.com/Loyalsoldier/geoip@latest | |
$(go env GOPATH)/bin/geoip convert -c config.json | |
cp output/dat/geoip.dat release | |
cp output/maxmind/Country.mmdb release | |
cp -fpPR output/text release | |
- name: Verify Country.mmdb files | |
run: | | |
go install -v github.com/maxmind/mmdbverify@latest | |
$(go env GOPATH)/bin/mmdbverify -file release/Country.mmdb | |
- name: Generate geosite.dat file | |
run: | | |
cd v2ray-geosite | |
mkdir data | |
cp ../release/ru-block.txt data/ru-block | |
go run ./ --datapath=data --outputdir=../release --outputname=geosite.dat | |
- name: Generate sha256sum | |
run: | | |
sha256sum release/geoip.dat > release/geoip.dat.sha256sum | |
sha256sum release/Country.mmdb > release/Country.mmdb.sha256sum | |
sha256sum release/geosite.dat > release/geosite.dat.sha256sum | |
- name: Generate Release Notes | |
run: | | |
echo "* Обновлён ${{ env.RELEASE_DATE }}" > RELEASE_NOTES | |
echo "* Кол-во заблокированных сайтов - ${{ env.RU_BLOCK }}" >> RELEASE_NOTES | |
- name: Push assets to release branch | |
run: | | |
cd release || 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 cache | |
run: | | |
cd release || exit 1 | |
for file in $(ls); do | |
curl -i "https://purge.jsdelivr.net/gh/${{ github.repository }}@release/${file}" | |
done | |
- name: Release and upload assets | |
uses: softprops/action-gh-release@v1 | |
with: | |
name: ${{ env.RELEASE_NAME }} | |
tag_name: ${{ env.TAG_NAME }} | |
body_path: RELEASE_NOTES | |
draft: false | |
prerelease: false | |
files: | | |
release/*.dat | |
release/*.mmdb | |
release/*.sha256sum | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
- name: Clean older releases | |
uses: dev-drprasad/delete-older-releases@v0.3.2 | |
with: | |
keep_latest: 7 | |
delete_tags: true | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |