Skip to content

baiduPush

baiduPush #146

Workflow file for this run

## 利用GitHub Actions每天定时给百度推送链接,提高收录率 ##
name: baiduPush
# 两种触发方式:一、push代码,二、每天国际标准时间23点(北京时间+8即早上7点)运行
on:
push:
schedule:
- cron: '0 23 * * *' # https://help.github.com/en/actions/automating-your-workflow-with-github-actions/events-that-trigger-workflows#scheduled-events-schedule
# on:
# schedule:
# - cron: '*/5 * * * *' # 每5分钟一次,测试用
jobs:
bot:
runs-on: ubuntu-latest # 运行在虚拟机环境ubuntu-latest
strategy:
matrix:
node-version: [18.x]
steps:
- name: Checkout # 步骤1
uses: actions/checkout@v1 # 使用的动作。格式:userName/repoName。作用:检出仓库,获取源码。 官方actions库:https://github.com/actions
- name: Use Node.js ${{ matrix.node-version }} # 步骤2
uses: actions/setup-node@v3 # 作用:安装nodejs
with:
node-version: ${{ matrix.node-version }} # 版本
- name: change base path
run: |
cd beiklive/.vuepress
search_str="/vuepresswiki/"
replace_str="/"
sed -i "s|$search_str|$replace_str|g" config.ts
echo "替换完成。"
- name: Build-and-deploy # 步骤3
run: |
yarn
yarn build
startpath="./beiklive/.vuepress/dist"
output_file="urls.txt"
base_url="http://doc.beiklive.top"
> "$output_file"
find "$startpath" -type f | while read -r file; do
relative_path="${file}"
full_url="${base_url}${relative_path}"
echo "$full_url" >> "$output_file"
done
replace_str=''
sed -i "s|$startpath|$replace_str|g" "$output_file"
cat "$output_file"
curl -H 'Content-Type:text/plain' --data-binary @urls.txt "http://data.zz.baidu.com/urls?site=doc.beiklive.top&token=wrUX2ETDK1sgdhZA"