Skip to content

update-friends-posts #2555

update-friends-posts

update-friends-posts #2555

Workflow file for this run

name: update-friends-posts
on:
push:
branches:
- main
schedule:
- cron: "0 0,6,12,18,21 * * *"
workflow_dispatch:
env:
# 在这里查看需要添加的secert
# 通用配置
SIMPLE_MODE: false # 极简模式是否开启
STORAGE_TYPE: ${{ secrets.STORAGE_TYPE }} # 请修改为你的存储方式,默认为leancloud
PROXY: ${{ secrets.PROXY }} # 可选,http代理
# leancloud、mysql、sqlite、mongodb配置四选一即可
# leancloud配置
APPID: ${{ secrets.APPID }}
APPKEY: ${{ secrets.APPKEY }}
# mysql配置
MYSQL_USERNAME: ${{ secrets.MYSQL_USERNAME }} # 登录用户名
MYSQL_PASSWORD: ${{ secrets.MYSQL_PASSWORD }} # 登录密码
MYSQL_IP: ${{ secrets.MYSQL_IP }} # 数据库IP地址
MYSQL_PORT: ${{ secrets.MYSQL_PORT }} # 数据库端口号
MYSQL_DB: ${{ secrets.MYSQL_DB }} # 要连接到的库的名称
# sqlite配置,用于将db文件上传到github仓库
GITHUB_NAME: ${{ secrets.GH_NAME }} # 你的github昵称
GITHUB_EMAIL: ${{ secrets.GH_EMAIL }} # 你的github邮箱
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }} # github token
# mongodb配置
MONGODB_URI: ${{ secrets.MONGODB_URI }} # mongodb URI 支持'mongodb://'和'mongodb+srv://'
TZ: Asia/Shanghai
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@main
- name: Set up Python
uses: actions/setup-python@main
with:
python-version: 3.8
- name: Install requirements
working-directory: ./hexo_circle_of_friends
run: |
pip install -r requirements.txt
- name: set env
run: |
echo "BASE_PATH=$(pwd)" >> $GITHUB_ENV && echo "PYTHONPATH=$(pwd)" >> $GITHUB_ENV
- name: leancloud Update posts # leancloud
if: ${{ env.STORAGE_TYPE == 'leancloud' }}
env:
APPID: ${{ secrets.APPID }}
APPKEY: ${{ secrets.APPKEY }}
LINK: ${{ secrets.LINK }}
PROXY: ${{ secrets.PROXY }}
working-directory: ./hexo_circle_of_friends
run: |
python run.py
- name: mysql Update posts # mysql
if: ${{ env.STORAGE_TYPE == 'mysql' }}
env:
MYSQL_USERNAME: ${{ secrets.MYSQL_USERNAME }}
MYSQL_PASSWORD: ${{ secrets.MYSQL_PASSWORD }}
MYSQL_IP: ${{ secrets.MYSQL_IP }}
MYSQL_DB: ${{ secrets.MYSQL_DB }}
working-directory: ./hexo_circle_of_friends
run: |
python run.py
- name: sqlite Update posts # sqlite
if: ${{ env.STORAGE_TYPE == 'sqlite' || env.SIMPLE_MODE == 'true' }}
env:
PYTHONPATH: ${{ env.PYTHONPATH }}
SQLITE_DB: ${{ secrets.SQLITE_DB }}
run: |
python ./hexo_circle_of_friends/run.py
- name: Push sqlite data # sqlite push
if: ${{ env.STORAGE_TYPE == 'sqlite' }}
uses: github-actions-x/[email protected]
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
commit-message: "Update data.db"
files: data.db
rebase: 'true'
name: ${{ env.GITHUB_NAME }}
email: ${{ env.GITHUB_EMAIL }}
- name: mongodb Update posts # mongodb
if: ${{ env.STORAGE_TYPE == 'mongodb' }}
env:
MONGODB_URI: ${{ secrets.MONGODB_URI }}
working-directory: ./hexo_circle_of_friends
run: |
python run.py
- name: simple mode transform # 极简模式转换
if: ${{ env.SIMPLE_MODE == 'true' }}
run: |
python ./hexo_circle_of_friends/utils/simple_mode_transform_json.py
- name: simple mode push # 推送极简模式
if: ${{ env.SIMPLE_MODE == 'true' }}
uses: github-actions-x/[email protected]
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
commit-message: "Update data.json"
files: data.json
rebase: 'true'
name: github-actions[bot]
email: [email protected]
- name: keep alive
uses: gautamkrishnar/keepalive-workflow@master # keep workflows from being suspended when no commit for a long time