Skip to content

Update GeoIP2 database #424

Update GeoIP2 database

Update GeoIP2 database #424

name: Update GeoIP2 database
on:
push:
branches: [ master ]
workflow_dispatch:
schedule:
- cron: '0 2 */3 * *'
jobs:
build:
name: Generate GeoIP2 database
runs-on: ubuntu-latest
steps:
- name: Set up Go 1.x
uses: actions/setup-go@v2
with:
go-version: ^1.14
id: go
- name: Check out code into the Go module directory
uses: actions/checkout@v2
- name: Get dependencies
run: |
go get -v -t -d ./...
if [ -f Gopkg.toml ]; then
curl https://raw.githubusercontent.com/golang/dep/master/install.sh | sh
dep ensure
fi
- name: Create dist folder
run: mkdir -p dist
- name: Compile GeoIP conversion bin (Golang)
run: ./build.sh
- name: Obtain CN IPv4 lists
run: |
wget -qO- "https://raw.githubusercontent.com/misakaio/chnroutes2/master/chnroutes.txt" | grep -v '#' > dist/chnroutes.txt
- name: Obtain CN IPv6 lists
run: |
wget -qO- "https://raw.githubusercontent.com/gaoyifan/china-operator-ip/ip-lists/china6.txt" | grep -v '#' >> dist/chnroutes.txt
- name: Generate GeoIP2 database
run: |
CURRENT_DIR=$(pwd)
cd dist
./ipip2mmdb -s ./chnroutes.txt -d Country.mmdb
cd $CURRENT_DIR
- name: Push artifacts to release branch
run: |
git config --local user.email "${{ github.actor }}@users.noreply.github.com"
git config --local user.name "github-action[bot]"
git fetch
git checkout release
git checkout --orphan release-orphan
git rm -rf .
cp -rf dist/chnroutes.txt ./
cp -rf dist/Country.mmdb ./
git add Country.mmdb
git add chnroutes.txt
git commit -am "Updated at $(date)"
git branch -D release
git branch -m release
- name: GitHub Push
uses: ad-m/[email protected]
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
branch: release
force: true