From c88294194bbc52fec1114156c910e8549aa6639d Mon Sep 17 00:00:00 2001 From: hect0x7 <93357912+hect0x7@users.noreply.github.com> Date: Thu, 16 Apr 2026 22:59:44 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E4=BC=98=E5=8C=96=20GitHub=20Actions?= =?UTF-8?q?=20=E5=90=88=E5=B9=B6=20PDF=20=E6=97=B6=E7=9A=84=E6=96=87?= =?UTF-8?q?=E4=BB=B6=E5=90=8D=E7=94=9F=E6=88=90=E8=A7=84=E5=88=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 原来使用简单的 `Aid` 或 `Pid` 进行命名,用户反馈导出的 PDF 名字全是数字看不出是什么。现在: 1. 默认情况下,本子维度的 PDF 命名为 `Atitle`,章节维度的 PDF 命名为 `Atitle_Ptitle`。 2. 新增可选的环境变量和 Action 面板输入参数 `PDF_NAME_RULE`,允许用户自定义生成规则。 --- .github/workflows/close_specific_pr.yml | 7 +++++++ .github/workflows/download_dispatch.yml | 7 +++++++ usage/workflow_download.py | 10 +++++++++- 3 files changed, 23 insertions(+), 1 deletion(-) diff --git a/.github/workflows/close_specific_pr.yml b/.github/workflows/close_specific_pr.yml index 74f9a4899..8ed49d3eb 100644 --- a/.github/workflows/close_specific_pr.yml +++ b/.github/workflows/close_specific_pr.yml @@ -26,6 +26,13 @@ jobs: run: | PR_TITLE=$(jq -r ".pull_request.title" $GITHUB_EVENT_PATH) echo "PR_TITLE: $PR_TITLE" + + # 检查标题是否符合 Conventional Commits 格式中的 feat 或 fix (不区分大小写) + if printf '%s\n' "$PR_TITLE" | grep -Eiq '(^|[[:space:]])(feat|fix)(\([^)]+\))?(!)?:'; then + echo "PR title contains feat or fix, skipping auto-close." + exit 0 + fi + gh pr comment ${{ github.event.pull_request.number }} --repo ${{ github.repository }} --body '${{ env.comment }}' gh pr close ${{ github.event.pull_request.number }} --repo ${{ github.repository }} env: diff --git a/.github/workflows/download_dispatch.yml b/.github/workflows/download_dispatch.yml index c45f94f49..86f132a60 100644 --- a/.github/workflows/download_dispatch.yml +++ b/.github/workflows/download_dispatch.yml @@ -40,6 +40,12 @@ on: - 是 | 本子维度合并pdf - 是 | 章节维度合并pdf + PDF_NAME_RULE: + type: string + description: 'PDF文件命名规则。支持字段如 Aid, Atitle, Pindex, Pid, Ptitle' + default: '' + required: false + ZIP_NAME: type: string default: 本子.tar.gz @@ -78,6 +84,7 @@ jobs: UPLOAD_NAME: ${{ github.event.inputs.UPLOAD_NAME }} IMAGE_SUFFIX: ${{ github.event.inputs.IMAGE_SUFFIX }} PDF_OPTION: ${{ github.event.inputs.PDF_OPTION }} + PDF_NAME_RULE: ${{ github.event.inputs.PDF_NAME_RULE }} # 登录相关secrets JM_USERNAME: ${{ secrets.JM_USERNAME }} diff --git a/usage/workflow_download.py b/usage/workflow_download.py index dea02af81..4f8121225 100644 --- a/usage/workflow_download.py +++ b/usage/workflow_download.py @@ -84,11 +84,19 @@ def cover_option_config(option: JmOption): pdf_option = env('PDF_OPTION', None) if pdf_option and pdf_option != '否': call_when = 'after_album' if pdf_option == '是 | 本子维度合并pdf' else 'after_photo' + + pdf_name_rule = env('PDF_NAME_RULE', None) + if isinstance(pdf_name_rule, str): + pdf_name_rule = pdf_name_rule.strip() + + if not pdf_name_rule: + pdf_name_rule = '[JM{Aid}] {Atitle}' if call_when == 'after_album' else '[JM{Aid}] 第{Pindex}章-JM{Pid}-{Ptitle}' + plugin = [{ 'plugin': Img2pdfPlugin.plugin_key, 'kwargs': { 'pdf_dir': option.dir_rule.base_dir + '/pdf/', - 'filename_rule': call_when[6].upper() + 'id', + 'filename_rule': pdf_name_rule, 'delete_original_file': True, } }]