work it on yml?
Some checks failed
自动生成 label / Generate-label (push) Failing after 23s

push

看起来还是得要node是吧

用这个

还得ensurepip是吧

用一下 setup python

reee

行

v4

?

还得是local
This commit is contained in:
shenjack 2023-12-09 02:03:41 +08:00
parent 58350f50a1
commit 61aab941bb
Signed by: shenjack
GPG Key ID: 7B1134A979775551
3 changed files with 55 additions and 19 deletions

View File

@ -1,18 +0,0 @@
name: 自动生成 label
# main 分支推送
on:
push:
branches:
- main
jobs:
Generate-label:
runs-on: python311
steps:
- name: 获取仓库
uses: http://shenjack.top:5100/mirror/checkout@v4
# - name: 生成 label
# run: |
# python3 generate_label.py

View File

@ -0,0 +1,30 @@
name: 自动生成 label
# main 分支推送
on:
[push]
# push:
# branches:
# - main
jobs:
Generate-label:
runs-on: node-21
steps:
- name: 获取仓库
uses: http://shenjack.top:5100/mirror/checkout@v4
- name: 安装 Python
uses: http://shenjack.top:5100/mirror/setup-python@v5
- name: 安装依赖
run: |
python3 -m ensurepip
python3 -m pip config set global.index-url https://pypi.tuna.tsinghua.edu.cn/simple
python3 -m pip install -U pip
python3 -m pip install mistune
- name: 生成 label
run: |
python3 generate_label.py

View File

@ -1,4 +1,28 @@
from pathlib import Path
from pprint import pprint
import mistune
ast_markdown = mistune.create_markdown(renderer='ast')
def read_files(module_path: Path):
...
with open(module_path, 'r', encoding='utf-8') as f:
file = f.read()
parsed = ast_markdown(file)
return parsed
if __name__ == '__main__':
module_path = Path('modules')
# walk through the modules
# for every markdown file
# parse the label
for md_file in module_path.rglob('*.md'):
print(md_file)
parsed = read_files(md_file)
pprint(parsed)