diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 00000000..410b2f6c --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,47 @@ +name: Build + +on: + push: + branches: [ '*' ] + pull_request: + branches: [ '*' ] + + workflow_dispatch: + schedule: + - cron: '45 2 * * *' + +jobs: + build: + runs-on: ubuntu-latest + env: + BGPTOOLS_VERSION: 0.0.3 + GO111MODULE: on + steps: + - uses: actions/checkout@v2 + - uses: actions-rs/toolchain@v1 + with: + toolchain: stable + - uses: actions/setup-go@v2 + - name: Setup Go environment variables + run: | + echo "GOPATH=$(go env GOPATH)" >> $GITHUB_ENV + echo "$(go env GOPATH)/bin" >> $GITHUB_PATH + - run: sudo apt-get install -y lftp bgpdump tree + - uses: actions/cache@v2 + with: + key: ${{ runner.os }}-build-dependencies + path: | + ~/go/bin + ~/.cargo/bin + - run: ./dependency.sh + - run: ./generate.sh + - run: ./stat.sh + - name: Checkout ip-lists branch + uses: actions/checkout@v2 + if: github.event_name == 'schedule' && github.ref == 'refs/heads/master' + with: + ref: ip-lists + path: ip-lists + - run: ./upload.sh + if: github.event_name == 'schedule' && github.ref == 'refs/heads/master' + diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 262c26b3..00000000 --- a/.travis.yml +++ /dev/null @@ -1,28 +0,0 @@ -dist: bionic -addons: - apt: - packages: - - lftp - - bgpdump - - tree -language: rust -cache: - cargo: true - directories: - - /home/travis/gopath/bin/ -env: - global: - - BGPTOOLS_VERSION=0.0.3 -install: - - export PATH=$PATH:$HOME/go/bin - - ./dependency.sh -script: - - ./generate.sh - - ./stat.sh -deploy: - provider: script - script: ./upload.sh - skip_cleanup: true - on: - branch: master - condition: $TRAVIS_EVENT_TYPE == cron diff --git a/README.md b/README.md index a5a0c8d5..579fb879 100644 --- a/README.md +++ b/README.md @@ -67,6 +67,7 @@ P.S. [stat文件](https://github.com/gaoyifan/china-operator-ip/blob/ip-lists/st * 感谢[boj](https://ring0.me)师兄提出的[设计建议](https://github.com/ustclug/discussions/issues/79#issuecomment-267958775) * 感谢[University of Oregon Route Views Archive Project](http://archive.routeviews.org)项目提供BGP数据源 * 感谢[Travis CI](https://travis-ci.org)提供优秀的持续集成平台 +* 感谢[GitHub](https://github.com/features/actions)提供计算资源 * 感谢[cidr-merger](https://github.com/zhanhb/cidr-merger)项目提供高效的IP地址合并工具 * 感谢[bgpdump](https://bitbucket.org/ripencc/bgpdump/wiki/Home)项目提供rib数据的读取工具 diff --git a/dependency.sh b/dependency.sh index 523700d7..b757714c 100755 --- a/dependency.sh +++ b/dependency.sh @@ -2,12 +2,9 @@ set -e -cidr-merger --version || { - curl -sL -o ~/bin/gimme https://raw.githubusercontent.com/travis-ci/gimme/master/gimme - chmod +x ~/bin/gimme - eval "$(gimme stable)" - go get github.com/zhanhb/cidr-merger -} +cidr-merger --version || \ + go get github.com/zhanhb/cidr-merger@v1.1.2 + bgptools --version | grep -F $BGPTOOLS_VERSION || \ cargo install --vers $BGPTOOLS_VERSION bgptools diff --git a/upload.sh b/upload.sh index ae31e6ab..43c5be25 100755 --- a/upload.sh +++ b/upload.sh @@ -1,13 +1,12 @@ #!/usr/bin/env bash -git clone -b ip-lists https://${GH_REF} ip-lists rm ip-lists/*.txt mv result/* ip-lists cd ip-lists tree -H . -P "*.txt|stat" -T "China Operator IP - prebuild results" > index.html -git config user.name $GIT_USER_NAME -git config user.email $GIT_USER_EMAIL +git config user.name GitHub Actions +git config user.email github-actions@github.com git add . git commit -m "update $(date +%Y-%m-%d)" -git push -q "https://${GH_TOKEN}@${GH_REF}" ip-lists:ip-lists +git push -q