Migrate from Travis CI to Github Actions (Fix #19)

This commit is contained in:
Yifan Gao 2021-08-10 07:26:16 +08:00
parent 595940b227
commit 1f899ff241
5 changed files with 54 additions and 38 deletions

47
.github/workflows/build.yml vendored Normal file
View File

@ -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'

View File

@ -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

View File

@ -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) * 感谢[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数据源 * 感谢[University of Oregon Route Views Archive Project](http://archive.routeviews.org)项目提供BGP数据源
* 感谢[Travis CI](https://travis-ci.org)提供优秀的持续集成平台 * 感谢[Travis CI](https://travis-ci.org)提供优秀的持续集成平台
* 感谢[GitHub](https://github.com/features/actions)提供计算资源
* 感谢[cidr-merger](https://github.com/zhanhb/cidr-merger)项目提供高效的IP地址合并工具 * 感谢[cidr-merger](https://github.com/zhanhb/cidr-merger)项目提供高效的IP地址合并工具
* 感谢[bgpdump](https://bitbucket.org/ripencc/bgpdump/wiki/Home)项目提供rib数据的读取工具 * 感谢[bgpdump](https://bitbucket.org/ripencc/bgpdump/wiki/Home)项目提供rib数据的读取工具

View File

@ -2,12 +2,9 @@
set -e set -e
cidr-merger --version || { cidr-merger --version || \
curl -sL -o ~/bin/gimme https://raw.githubusercontent.com/travis-ci/gimme/master/gimme go get github.com/zhanhb/cidr-merger@v1.1.2
chmod +x ~/bin/gimme
eval "$(gimme stable)"
go get github.com/zhanhb/cidr-merger
}
bgptools --version | grep -F $BGPTOOLS_VERSION || \ bgptools --version | grep -F $BGPTOOLS_VERSION || \
cargo install --vers $BGPTOOLS_VERSION bgptools cargo install --vers $BGPTOOLS_VERSION bgptools

View File

@ -1,13 +1,12 @@
#!/usr/bin/env bash #!/usr/bin/env bash
git clone -b ip-lists https://${GH_REF} ip-lists
rm ip-lists/*.txt rm ip-lists/*.txt
mv result/* ip-lists mv result/* ip-lists
cd ip-lists cd ip-lists
tree -H . -P "*.txt|stat" -T "China Operator IP - prebuild results" > index.html tree -H . -P "*.txt|stat" -T "China Operator IP - prebuild results" > index.html
git config user.name $GIT_USER_NAME git config user.name GitHub Actions
git config user.email $GIT_USER_EMAIL git config user.email github-actions@github.com
git add . git add .
git commit -m "update $(date +%Y-%m-%d)" git commit -m "update $(date +%Y-%m-%d)"
git push -q "https://${GH_TOKEN}@${GH_REF}" ip-lists:ip-lists git push -q