🔝 利用Github Actions 通过Serve酱自动发送微博、知乎、v2ex热门内容到微信,可配置 workflow 的触发条件为 schedule,实现周期性定时发送热门内容。
项目地址
ServerChan-Push
示例
clone 此 GitHub 仓库,修改.github/workflows/ 文件夹下一个 main.yml 文件,内容如下:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37
| name: 'Push News'
on: push: branches: - master schedule: - cron: '0 */3 * * *' watch: types: [started]
env: TZ: Asia/Shanghai
jobs: Gitfolio-Spider: runs-on: ubuntu-latest steps: - name: Checkout uses: actions/checkout@v2 - name: 'Set up Python' uses: actions/setup-python@v2 with: python-version: 3.8 - name: 'Install dependencies' run: python -m pip install --upgrade pip - name: 'Install requirements' run: pip install -r ./requirements.txt - name: 'Working' env: SECRET: ${{ secrets.SECRET }} timeout-minutes: 350 run: | echo SECRET=$SECRET > .env python main.py rm -f .env
|
注意
- cron 是 UTC 时间,使用时请将北京时间转换为 UTC 进行配置。
- 请在项目的 Settings -> Secrets 路径下配置好SECRET(server酱密钥),不要直接在 .yml 文件中暴露地址跟密钥
- SECRET 设置为
xxxxxx
效果
