Skip to content

Introduce a new GitHub Action from the pandoc repo #162

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 16 commits into from
Sep 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
62 changes: 62 additions & 0 deletions .github/actions/render/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
name: 'Render'
description: 'Render a TCG Markdown document'
inputs:
input-md:
description: 'The name of the Markdown file to render'
required: true
output-basename:
description: 'The base name (without extension) to use for output file(s)'
required: true
pr-repo:
description: 'Pull request repo (use with pr-number)'
required: false
type: 'string'
pr-number:
description: 'Pull request number to reference (use with pr-repo)'
required: false
type: 'string'
pdf:
description: 'Render to PDF'
required: false
type: 'boolean'
default: 'true'
diffbase:
description: 'The revision to diff against (use with pdf)'
required: false
type: 'string'
html:
description: 'Render to HTML'
required: false
type: 'boolean'
default: 'false'
docx:
description: 'Render to Word'
required: false
type: 'boolean'
default: 'false'
tex:
description: 'Render to TeX'
required: false
type: 'boolean'
default: 'false'
extra-build-options:
description: 'Additional build options to be passed to build.sh'
runs:
using: 'composite'
steps:
# let the container take ownership of the repo dir, in case the user wants to check in the results
# workaround to https://github.com/actions/runner/issues/2033
- run: chown -R $(id -u):$(id -g) $PWD
shell: sh
- run: >
/usr/bin/build.sh
--versioned_filenames
$( [ -n "${{ inputs.pr-repo }}" -a -n "${{ inputs.pr-number }}" ] && echo --pr_number=${{ inputs.pr-number }} --pr_repo=${{ inputs.pr-repo }} )
$( [ ${{ inputs.pdf }} -a -n "${{ inputs.diffbase }}" ] && echo --diffbase=${{ inputs.diffbase }} --diffpdf=${{ inputs.output-basename }}.diff.pdf --diffpdflog=${{ inputs.output-basename }}.diff.pdf.log )
$( ${{ inputs.pdf }} && echo --pdf=${{ inputs.output-basename }}.pdf --pdflog=${{ inputs.output-basename }}.pdf.log )
$( ${{ inputs.html }} && echo --html=${{ inputs.output-basename }}.html )
$( ${{ inputs.docx }} && echo --docx=${{ inputs.output-basename }}.docx )
$( ${{ inputs.tex }} && echo --latex=${{ inputs.output-basename }}.tex )
${{ inputs.extra-build-options }}
${{ inputs.input-md }}
shell: sh
2 changes: 1 addition & 1 deletion .github/workflows/docker-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ jobs:
# Login against a Docker registry
# https://github.com/docker/login-action
- name: Log into registry
uses: docker/login-action@v2
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
Expand Down
23 changes: 17 additions & 6 deletions .github/workflows/render-samples.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
# Login against a Docker registry
# https://github.com/docker/login-action
- name: Log into registry
uses: docker/login-action@v2
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
Expand Down Expand Up @@ -68,25 +68,36 @@ jobs:
*.lof
*.lot
*.toc
*.upa
*.upb
*.convert.pdf
key: latex-${{ github.run_id }}
restore-keys: latex

- name: Run the action on guide
uses: trustedcomputinggroup/markdown@latest
uses: ./.github/actions/render
with:
input-md: guide.tcg
extra-build-options: "--versioned_filenames --pr_number=${{ github.event.number }} --pr_repo=${{ github.repository }} --diffbase=${{ github.event.pull_request.base.sha }}"
output-pdf: guide.pdf
output-tex: guide.tex
output-docx: guide.docx
output-basename: guide
pdf: true
tex: true
docx: true
diffbase: "${{ github.event.pull_request.base.sha }}"
pr-number: "${{ github.event.number }}"
pr-repo: "${{ github.repository }}"

- name: Upload PDF
uses: actions/upload-artifact@master
with:
name: PDF
path: guide.*.pdf

- name: Upload logs
uses: actions/upload-artifact@master
with:
name: Logs
path: guide.*.log

- name: Upload TeX
uses: actions/upload-artifact@master
with:
Expand Down
38 changes: 21 additions & 17 deletions build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -378,7 +378,7 @@ if [ "${VERSIONED_FILENAMES}" == "yes" ]; then
PDF_OUTPUT=$(prefix_filename "${version_prefix}" "${PDF_OUTPUT}")
fi
if [ ! -z "${DIFFPDF_OUTPUT}" ]; then
DIFFPDF_OUTPUT=$(prefix_filename "${DIFFBASE}_to_${version_prefix}" "${DIFFPDF_OUTPUT}")
DIFFPDF_OUTPUT=$(prefix_filename ".$(echo ${DIFFBASE} | cut -c1-10).to${version_prefix}" "${DIFFPDF_OUTPUT}")
fi
if [ ! -z "${LATEX_OUTPUT}" ]; then
LATEX_OUTPUT=$(prefix_filename "${version_prefix}" "${LATEX_OUTPUT}")
Expand Down Expand Up @@ -778,22 +778,26 @@ readonly TEMP_DIFF_TEX_FILE="${BUILD_DIR}/${INPUT_FILE}.diff.tex"
readonly TEMP_LATEXDIFF_LOG="${BUILD_DIR}/latexdiff.log"
export MERMAID_FILTER_FORMAT="pdf"
if [ -n "${DIFFPDF_OUTPUT}" ]; then
git reset --hard ${DIFFBASE}

do_md_fixups "${BUILD_DIR}/${INPUT_FILE}"
do_latex "${BUILD_DIR}/${INPUT_FILE}" "${TEMP_DIFFBASE_TEX_FILE}"
latexdiff --type PDFCOMMENT --driver "${PDF_ENGINE}" "${TEMP_DIFFBASE_TEX_FILE}" "${TEMP_TEX_FILE}" > "${TEMP_DIFF_TEX_FILE}" 2>"${TEMP_LATEXDIFF_LOG}"
do_tex_fixups "${TEMP_DIFF_TEX_FILE}"
do_pdf "${TEMP_DIFF_TEX_FILE}" "${SOURCE_DIR}/${DIFFPDF_OUTPUT}" "${LATEX_LOG}"

# Copy the logs, if requested. Note that this file gets the latexdiff and PDF driver output.
if [ -n "${DIFFPDFLOG_OUTPUT}" ]; then
mkdir -p "$(dirname ${SOURCE_DIR}/${DIFFPDFLOG_OUTPUT})"
echo "latexdiff output:" > "${SOURCE_DIR}/${DIFFPDFLOG_OUTPUT}"
cat "${TEMP_LATEXDIFF_LOG}" >> "${SOURCE_DIR}/${DIFFPDFLOG_OUTPUT}"
echo "" >> "${SOURCE_DIR}/${DIFFPDFLOG_OUTPUT}"
echo "${PDF_ENGINE} output:" >> "${SOURCE_DIR}/${DIFFPDFLOG_OUTPUT}"
cat "${LATEX_LOG}" >> "${SOURCE_DIR}/${DIFFPDFLOG_OUTPUT}"
git fetch --unshallow --quiet && git reset --hard ${DIFFBASE}
if [ $? -ne 0 ]; then
FAILED=true
echo "diff output failed"
else
do_md_fixups "${BUILD_DIR}/${INPUT_FILE}"
do_latex "${BUILD_DIR}/${INPUT_FILE}" "${TEMP_DIFFBASE_TEX_FILE}"
latexdiff --type PDFCOMMENT --driver "${PDF_ENGINE}" "${TEMP_DIFFBASE_TEX_FILE}" "${TEMP_TEX_FILE}" > "${TEMP_DIFF_TEX_FILE}" 2>"${TEMP_LATEXDIFF_LOG}"
do_tex_fixups "${TEMP_DIFF_TEX_FILE}"
do_pdf "${TEMP_DIFF_TEX_FILE}" "${SOURCE_DIR}/${DIFFPDF_OUTPUT}" "${LATEX_LOG}"

# Copy the logs, if requested. Note that this file gets the latexdiff and PDF driver output.
if [ -n "${DIFFPDFLOG_OUTPUT}" ]; then
mkdir -p "$(dirname ${SOURCE_DIR}/${DIFFPDFLOG_OUTPUT})"
echo "latexdiff output:" > "${SOURCE_DIR}/${DIFFPDFLOG_OUTPUT}"
cat "${TEMP_LATEXDIFF_LOG}" >> "${SOURCE_DIR}/${DIFFPDFLOG_OUTPUT}"
echo "" >> "${SOURCE_DIR}/${DIFFPDFLOG_OUTPUT}"
echo "${PDF_ENGINE} output:" >> "${SOURCE_DIR}/${DIFFPDFLOG_OUTPUT}"
cat "${LATEX_LOG}" >> "${SOURCE_DIR}/${DIFFPDFLOG_OUTPUT}"
fi
fi
fi

Expand Down
Loading