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, } }]