From 293b1a28be585167feed5d96af8bf0955af8d1d7 Mon Sep 17 00:00:00 2001 From: Steven Yang Date: Sun, 5 Feb 2023 18:24:08 +0800 Subject: [PATCH] Migrate from Travis CI to Github Actions --- .github/workflows/build.yml | 41 +++++++++++++++++++++++++++++++++++++ .travis.yml | 24 ---------------------- dependency.sh | 5 +---- guard.sh | 7 +++++++ upload.sh | 9 ++++---- 5 files changed, 53 insertions(+), 33 deletions(-) create mode 100644 .github/workflows/build.yml delete mode 100644 .travis.yml create mode 100755 guard.sh diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 000000000..e9a21382b --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,41 @@ +name: Build + +on: + push: + branches: [ '*' ] + pull_request: + branches: [ '*' ] + + workflow_dispatch: + schedule: + - cron: '30 4 * * *' + +jobs: + build: + runs-on: ubuntu-latest + env: + BGPTOOLS_VERSION: 0.0.3 + GO111MODULE: on + steps: + - uses: actions/checkout@v3 + - uses: actions/setup-go@v2 + with: + go-version: 1.16 + - run: sudo apt-get install -y bgpdump build-essential git + - uses: actions/cache@v3 + with: + key: ${{ runner.os }}-build-dependencies + path: | + ~/go/bin + - run: ./dependency.sh + - run: ./generate.sh + - run: ./stat.sh + - run: ./guard.sh + - name: Checkout ip-lists branch + uses: actions/checkout@v3 + 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 7d96f4b6c..000000000 --- a/.travis.yml +++ /dev/null @@ -1,24 +0,0 @@ -dist: focal -addons: - apt: - packages: - - bgpdump - - build-essential - - git -language: bash -cache: - directories: - - /home/travis/gopath/bin/ -install: - - export PATH=$PATH:$HOME/go/bin - - ./dependency.sh -script: - - travis_wait 60 ./generate.sh - - ./stat.sh -deploy: - provider: script - script: ./upload.sh - skip_cleanup: true - on: - branch: master - condition: $TRAVIS_EVENT_TYPE == cron diff --git a/dependency.sh b/dependency.sh index d47c9713b..1a184a4a1 100755 --- a/dependency.sh +++ b/dependency.sh @@ -3,10 +3,7 @@ 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 + go install github.com/zhanhb/cidr-merger@v1.1.2 } asroute 0 < /dev/null || { git clone https://github.com/yangzhaofeng/aspathanalysis.git diff --git a/guard.sh b/guard.sh new file mode 100755 index 000000000..8980be825 --- /dev/null +++ b/guard.sh @@ -0,0 +1,7 @@ +#!/bin/bash + +[[ $(wc -l result/china.txt) < 3000 ]] && exit 1 + +[[ $(wc -l result/china6.txt) < 1000 ]] && exit 2 + +exit 0 diff --git a/upload.sh b/upload.sh index 513e21989..ef8a5fb55 100755 --- a/upload.sh +++ b/upload.sh @@ -1,12 +1,11 @@ #!/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 -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 "https://${GH_TOKEN}@${GH_REF}" ip-lists:gh-pages +git push -q