forked from Rock-Candy-Tea/hexo-circle-of-friends
-
Notifications
You must be signed in to change notification settings - Fork 0
122 lines (108 loc) · 3.9 KB
/
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
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/commit@v2.9
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/commit@v2.9
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
commit-message: "Update data.json"
files: data.json
rebase: 'true'
name: github-actions[bot]
email: github-actions@noreply.github.com
- name: keep alive
uses: gautamkrishnar/keepalive-workflow@master # keep workflows from being suspended when no commit for a long time