Cron Release #55
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Cron Release | |
on: | |
# push: | |
# branches: [ master ] | |
schedule: | |
- cron: 0 0 20 * * | |
jobs: | |
build: | |
name: Build | |
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: buildAction | |
run: ./build.sh | |
- name: Get china_ip_list.txt | |
run: curl -LR -o dist/china_ip_list.txt "https://raw.githubusercontent.com/17mon/china_ip_list/master/china_ip_list.txt" | |
- name: Transform china_ip_list to MaxMind mmdb | |
run: | | |
cd dist | |
./ipip2mmdb -s ./china_ip_list.txt -d Country.mmdb | |
- name: Set env variables | |
run: | | |
echo "RELEASE_NAME=$(date +%Y%m%d)" >> $GITHUB_ENV | |
echo "TAG_NAME=$(date +%Y%m%d)" >> $GITHUB_ENV | |
shell: bash | |
- name: Generate version file | |
run: | | |
cd dist | |
echo $TAG_NAME > version | |
- name: Push to release branch | |
run: | | |
mkdir publish | |
cp -af dist/version publish/version | |
cp -af dist/Country.mmdb publish/Country.mmdb | |
cd publish | |
git init | |
git config --local user.name "${{ github.actor }}" | |
git config --local user.email "${{ github.actor }}@users.noreply.github.com" | |
git checkout -b release | |
git add . | |
git commit -m "${{ env.RELEASE_NAME }}" | |
git remote add origin "https://${{ github.actor }}:${{ secrets.CRON_RELEASE_WORKFLOW }}@github.com/${{ github.repository }}" | |
git push -f -u origin release |