You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

GitHub Action中Pandoc+GNU Parallel转换文件的问题排查

GitHub Action中Pandoc+Parallel转换Markdown无输出文件排查

我配置了如下GitHub Action,通过condition_check_files获取主分支推送时新增及修改的Markdown文件,用Pandoc结合GNU Parallel将其转换为多种格式:

conditional_pandoc:
  runs-on: 'ubuntu-22.04'
  needs: [ condition_check_files ]
  if: needs.condition_check_files.outputs.bool_files_changed == 'True'
  env:
    list_changed_files: ${{ needs.condition_check_files.outputs.list_changed_files }}
  steps:
    - name: install_pandoc
      uses: pandoc/actions/setup@v1
      with:
        version: 3.5
    - name: run_pandoc
      run: >
        # List types which will only use --standalone. You can easily add more extensions if you're fine with this setting
        $ONLY_STANDALONE_OUTPUT_TYPES = "latex pdf html docx odt"';' \
        parallel --jobs 0 \
          # Pandoc creates an AST (Abstract Syntax Tree); reuse this by saving/reading from .ast
          pandoc --from markdown {} --to native -o '{.}.ast' ';'
          for i in $ONLY_STANDALONE_OUTPUT_TYPES';' do \
            pandoc --from native '{.}.ast' --standalone -o '{.}.$i' ';' \
          done';' \
          # You can easily add individual conversion rules by using pandoc after the 'done' part. Keep in mind to finish all non-comment lines with backslash
          rm '{.}.ast' ::: $env:list_changed_files

推送修改后的.md文件时,任务报错:

pandoc: {}: withBinaryFile: does not exist (No such file or directory)
Error: Process completed with exit code 1.

编辑一:移除注释后的新报错

按照建议移除注释后,出现新错误:

Run $ONLY_STANDALONE_OUTPUT_TYPES = "latex pdf html docx odt"';' \ parallel --jobs 0 \
/home/runner/work/_temp/57d44aa5-ea88-4a42-b677-caf9210aa3af.sh: line 1: =: command not found
Error: Process completed with exit code 127.

编辑二:无报错但输出文件丢失

参考建议调试后得到如下配置:

- name: run_pandoc
  env:
    Only_Standalone_Output_Types: "latex pdf html docx odt"
  run: |
    parallel --jobs 0 \
      pandoc --from markdown --to native {} -o '{.}.ast' ';' \
      for i in $Only_Standalone_Output_Types';' do \
        pandoc --from native '{.}.ast' --standalone -o '{.}.$i' ';' \
      done';' \
      rm '{.}.ast' ::: $list_changed_files

现在Action执行无报错,但找不到输出文件。本地运行如下bash脚本可正常生成文件:

#!/bin/bash

test_files="test.md test/beispiel.md"
OUTPUT_TYPES="latex pdf html docx odt"

parallel --jobs 0 \
    pandoc --from markdown --to native {} -o '{.}.ast' ';' \
    for i in $OUTPUT_TYPES';' do \
        pandoc --from native '{.}.ast' --standalone -o '{.}.$i' ';' \
    done';' \
    rm '{.}.ast' ::: $test_files

恳请帮忙排查输出文件丢失的问题。


内容的提问来源于stack exchange,提问作者GH-MK

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.16 12:27:46