Skip to content

Commit bb1b9ab

Browse files
authored
ci: decoupling with cloudflare KV (#3)
1 parent 7732b16 commit bb1b9ab

File tree

3 files changed

+5
-38
lines changed

3 files changed

+5
-38
lines changed

.github/workflows/build.yml

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Deploy
1+
name: Build & Release on Tagged Commit
22

33
on:
44
push:
@@ -11,20 +11,13 @@ permissions:
1111
jobs:
1212
build:
1313
runs-on: ubuntu-latest
14-
name: Build
14+
name: Build & Release
1515
steps:
1616
- uses: actions/checkout@v2
17-
- uses: actions/setup-node@v3
18-
with:
19-
node-version: 16
2017
- uses: actions/setup-python@v4
2118
with:
2219
python-version: '3.10'
23-
- run: npm i -g wrangler
24-
- run: python3 make.py --publish
25-
env:
26-
CLOUDFLARE_API_TOKEN: ${{ secrets.CF_API_TOKEN }}
27-
CLOUDFLARE_ACCOUNT_ID: 171f09ad4e5e98bf4de28d465e116904
20+
- run: python3 make.py
2821
- uses: softprops/action-gh-release@v1
2922
with:
3023
files: |

.github/workflows/lint.yml

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,13 @@
1-
name: Lint Database
1+
name: Lint on Push / Pull Request
22
on: [push, pull_request]
33

44
jobs:
55
build:
66
runs-on: ubuntu-latest
7-
name: Lint Database
7+
name: Lint
88
steps:
99
- uses: actions/checkout@v2
10-
- uses: actions/setup-node@v3
11-
with:
12-
node-version: 16
1310
- uses: actions/setup-python@v4
1411
with:
1512
python-version: '3.10'
16-
- run: npm i -g wrangler
1713
- run: python3 make.py

make.py

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
import sys
44
import json
55
import shutil
6-
import argparse
76

87
class FILENAMES:
98
SOURCE_DATABASE = 'database.txt'
@@ -180,31 +179,10 @@ def build_copy():
180179
print_file_size(FILENAMES.DIST_DB)
181180

182181

183-
def build_publish(namespace_id: str):
184-
if not os.path.exists(FILENAMES.DIST_JSON):
185-
print(colored('red', 'Error:'), f"文件 {FILENAMES.DIST_JSON} 不存在, build_publish 必须在 build_json 之后执行")
186-
sys.exit(-2)
187-
result = os.system(f"wrangler kv:key put --namespace-id {namespace_id} fortune-lyric --path {FILENAMES.DIST_JSON}")
188-
if result != 0:
189-
print(colored('yellow', 'Info:'), "命令返回值:", result)
190-
print(colored('red', 'Error:'), 'wrangler kv:key put 执行失败')
191-
sys.exit(-2)
192-
print(colored('green', 'Success:'), 'wrangler kv:key put 执行成功')
193-
194-
195182
if __name__ == '__main__':
196-
parser = argparse.ArgumentParser()
197-
parser.add_argument('--publish', action='store_true', help='发布到 Cloudflare KV')
198-
args = parser.parse_args()
199-
200-
if not args.publish:
201-
print(colored('yellow', 'Info:'), '如需发布到 Cloudflare KV,请使用 --publish 参数。')
202-
203183
database = load()
204184
build_json(database)
205185
build_text(database)
206186
build_bash(database)
207187
build_bash_multiline(database)
208188
build_copy()
209-
if args.publish:
210-
build_publish("0addc370401c4b77b57c9d40fddf9ad6")

0 commit comments

Comments
 (0)