Skip to content

Build geosite

Build geosite #98

Workflow file for this run

name: Build geosite
on:
workflow_dispatch:
schedule:
- cron: "30 22 * * *"
push:
branches:
- master
paths-ignore:
- "**/README.md"
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Set variables
run: |
echo "RELEASE_NAME=$(date +%Y%m%d%H%M)" >> $GITHUB_ENV
echo "TAG_NAME=$(date +%Y%m%d%H%M)" >> $GITHUB_ENV
- name: Fetch rules
run: |
wget "https://raw.githubusercontent.com/felixonmars/dnsmasq-china-list/master/apple.china.conf" -O apple.txt
wget "https://raw.githubusercontent.com/Loyalsoldier/domain-list-custom/release/icloud.txt" -O icloud.txt
wget "https://raw.githubusercontent.com/Loyalsoldier/domain-list-custom/release/private.txt" -O private.txt
wget "https://raw.githubusercontent.com/v2fly/domain-list-community/release/cn.txt" -O cn.txt
wget "https://raw.githubusercontent.com/Loyalsoldier/v2ray-rules-dat/release/gfw.txt" -O gfw.txt
shell: bash
- name: Generate apple.yaml file
run: |
echo "payload:" > apple.yaml
perl -ne '/^server=\/([^\/]+)\// && print " - |+.$1|\n"' apple.txt | sed "s/|/'/g" >> apple.yaml
grep -E "^(full|domain):" apple.txt | awk -F ':' '{printf " - |+.%s|\n", $2}' | sed "s/|/'/g" >> apple.yaml
- name: Generate private.yaml file
run: |
echo "payload:" > private.yaml
awk -F ':' '/^full:/ {printf " - |%s|\n", $2}' private.txt | sed "s/|/'/g" >> private.yaml
awk -F ':' '/^domain:/ {printf " - |+.%s|\n", $2}' private.txt | sed "s/|/'/g" >> private.yaml
- name: Generate cn.yaml file
run: |
echo "payload:" > cn.yaml
grep -Ev "^(regexp|keyword):" cn.txt | perl -ne '/^(full:)([-_a-zA-Z0-9]+(\.[-_a-zA-Z0-9]+)*)/ && print " - |$2|\n"' | sed "s/|/'/g" >> cn.yaml
grep -Ev "^(regexp|keyword|full):" cn.txt | perl -ne '/^(domain:)?([-_a-zA-Z0-9]+(\.[-_a-zA-Z0-9]+)*)/ && print " - |+.$2|\n"' | sed "s/|/'/g" >> cn.yaml
- name: Generate gfw.yaml file
run: |
echo "payload:" > gfw.yaml
grep -Ev "^(regexp|keyword):" gfw.txt | perl -ne '/^(domain:|full:)?([-_a-zA-Z0-9]+(\.[-_a-zA-Z0-9]+)*)/ && print " - |+.$2|\n"' | sed "s/|/'/g" >> gfw.yaml
- name: Move files to publish directory
run: |
mkdir -p publish
cp *.yaml ./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 "mcha0"
git config --local user.email "[email protected]"
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