Generate CUSTOM-GEOSITE #48
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 CUSTOM-GEOSITE | |
on: | |
workflow_dispatch: | |
schedule: | |
- cron: "0 0 * * 4" | |
push: | |
branches: | |
- master | |
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 | |
echo "googleUrl=https://raw.githubusercontent.com/blackmatrix7/ios_rule_script/master/rule/Clash/Google/Google.list" >> $GITHUB_ENV | |
echo "telegramUrl=https://raw.githubusercontent.com/blackmatrix7/ios_rule_script/master/rule/Clash/Telegram/Telegram.list" >> $GITHUB_ENV | |
echo "openaiUrl=https://raw.githubusercontent.com/blackmatrix7/ios_rule_script/master/rule/Clash/OpenAI/OpenAI.list" >> $GITHUB_ENV | |
echo "youtubeUrl=https://raw.githubusercontent.com/blackmatrix7/ios_rule_script/master/rule/Clash/YouTube/YouTube.list" >> $GITHUB_ENV | |
echo "microsoftUrl=https://raw.githubusercontent.com/blackmatrix7/ios_rule_script/master/rule/Clash/Microsoft/Microsoft.list" >> $GITHUB_ENV | |
echo "fcmUrl=https://raw.githubusercontent.com/blackmatrix7/ios_rule_script/master/rule/Clash/GoogleFCM/GoogleFCM.list" >> $GITHUB_ENV | |
echo "facebookUrl=https://raw.githubusercontent.com/blackmatrix7/ios_rule_script/master/rule/Clash/Facebook/Facebook.list" >> $GITHUB_ENV | |
echo "twitterUrl=https://raw.githubusercontent.com/blackmatrix7/ios_rule_script/master/rule/Clash/Twitter/Twitter.list" >> $GITHUB_ENV | |
echo "bingUrl=https://raw.githubusercontent.com/blackmatrix7/ios_rule_script/master/rule/Clash/Bing/Bing.list" >> $GITHUB_ENV | |
echo "adblockUrl=https://raw.githubusercontent.com/blackmatrix7/ios_rule_script/master/rule/Clash/Advertising/Advertising.list" >> $GITHUB_ENV | |
echo "cnUrl=https://raw.githubusercontent.com/blackmatrix7/ios_rule_script/master/rule/Clash/ChinaMax/ChinaMax.list" >> $GITHUB_ENV | |
shell: bash | |
- name: Checkout v2fly/domain-list-community | |
uses: actions/checkout@v4 | |
with: | |
repository: v2fly/domain-list-community | |
ref: master | |
path: community | |
- name: Setup Go | |
uses: actions/setup-go@v4 | |
with: | |
go-version-file: ./community/go.mod | |
cache-dependency-path: ./community/go.sum | |
- name: Build geosite.dat file | |
env: | |
NO_SKIP: true | |
SED: grep -E "^(DOMAIN|DOMAIN-SUFFIX|DOMAIN-KEYWORD)" | sed "s/^DOMAIN,/full:/g" | sed "s/^DOMAIN-SUFFIX,//g" | sed "s/DOMAIN-KEYWORD,/keyword:/g" | |
run: | | |
cd community || exit 1 | |
rm -rf data | |
mkdir -p data | |
curl -sSL ${cnUrl} | ${{ env.SED }} > ./data/cn | |
curl -sSL ${googleUrl} | ${{ env.SED }} > ./data/google | |
curl -sSL ${telegramUrl} | ${{ env.SED }} > ./data/telegram | |
curl -sSL ${youtubeUrl} | ${{ env.SED }} > ./data/youtube | |
curl -sSL ${microsoftUrl} | ${{ env.SED }} > ./data/microsoft | |
curl -sSL ${fcmUrl} | ${{ env.SED }} > ./data/fcm | |
curl -sSL ${bingUrl} | ${{ env.SED }} > ./data/bing | |
curl -sSL ${facebookUrl} | ${{ env.SED }} > ./data/social | |
curl -sSL ${twitterUrl} | ${{ env.SED }} >> ./data/social | |
curl -sSL ${openaiUrl} | ${{ env.SED }} > ./data/openai | |
go run ./ --datapath=./data --outputname geosite.dat | |
- name: Build db and metadb file | |
env: | |
NO_SKIP: true | |
run: | | |
go install -trimpath -ldflags="-s -w -buildid=" github.com/metacubex/geo/cmd/geo@master | |
geo convert site -i v2ray -o sing -f geosite.db ./community/geosite.dat | |
- name: Move and zip files | |
run: | | |
mkdir -p ./publish/ | |
install -Dp ./community/geosite.dat ./publish/ | |
install -Dp ./geosite.db ./publish/ | |
cd ./publish || exit 1 | |
- name: Delete current release assets | |
uses: andreaswilli/delete-release-assets-action@v3.0.0 | |
with: | |
github_token: ${{ secrets.GITHUB_TOKEN }} | |
tag: latest | |
deleteOnlyFromDrafts: false | |
- 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 "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 -u 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 |