Skip to content

chn-ip-task

chn-ip-task #3614

Workflow file for this run

name: chn-ip-task
on:
push: # push触发
branches: [ master ]
workflow_dispatch: # 手动触发
schedule: # 计划任务触发
- cron: '0 */8 * * *' # cron表达式,Actions时区是UTC时间,所以要往前推8个小时,如上表示每天14点10分
jobs:
run-get-ip-list:
runs-on: ubuntu-latest
steps:
# 检出
- name: Checkout
uses: actions/checkout@v2
# 设置服务器时区为东八区
- name: Set time zone
run: sudo timedatectl set-timezone 'Asia/Shanghai'
# .Net Core 环境
- name: Setup .NET Core
uses: actions/setup-dotnet@v1
with:
dotnet-version: 3.1.301
# 安装依赖
- name: Install dependencies
run: dotnet restore
# 构建应用
- name: Build
run: dotnet build --configuration Release --no-restore
# 运行应用
- name: Run
run: dotnet run china_ip_list.dll
# 本地提交
- name: Commit files
run: |
git config --local user.email "mayax@github.com"
git config --local user.name "mayaxcn"
ls
pwd
git rm chn_ip.txt
git rm chnroute.txt
git rm chn_ip_v6.txt
git rm chnroute_v6.txt
git commit -m "删除旧有IP文件!"
cp /home/runner/work/china-ip-list/china-ip-list/bin/Debug/netcoreapp3.1/chn_ip.txt /home/runner/work/china-ip-list/china-ip-list/chn_ip.txt
cp /home/runner/work/china-ip-list/china-ip-list/bin/Debug/netcoreapp3.1/chnroute.txt /home/runner/work/china-ip-list/china-ip-list/chnroute.txt
cp /home/runner/work/china-ip-list/china-ip-list/bin/Debug/netcoreapp3.1/chn_ip_v6.txt /home/runner/work/china-ip-list/china-ip-list/chn_ip_v6.txt
cp /home/runner/work/china-ip-list/china-ip-list/bin/Debug/netcoreapp3.1/chnroute_v6.txt /home/runner/work/china-ip-list/china-ip-list/chnroute_v6.txt
git add chn_ip.txt
git add chnroute.txt
git add chn_ip_v6.txt
git add chnroute_v6.txt
git commit -m "提交新的chn_ip.txt和chnroute.txt文件,更新于$(date "+%Y-%m-%d %H:%M:%S")"
# 更新至远程github代码仓库中
- name: Push changes
uses: ad-m/github-push-action@master
with:
github_token: ${{ secrets.CHNIP_GIT_KEY }}
branch: master