Skip to content

Commit

Permalink
Use mounted volume path for generated pdfs
Browse files Browse the repository at this point in the history
  • Loading branch information
ebullient committed Jan 29, 2024
1 parent a113efc commit 6cf779c
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 11 deletions.
23 changes: 13 additions & 10 deletions .github/docker-build-pdf.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,21 @@ if [[ -z "${PANDOCK}" ]]; then
PANDOCK=ebullient/pandoc-emoji:3.1
fi
# Git commit information (SHA, date, repo url)
if [[ -z "${GIT_COMMIT}" ]]; then
GIT_COMMIT=$(git rev-parse HEAD)
DATE=$(date "+%Y-%m-%d")
if [[ "${IS_PR}" == "true" ]]; then
FOOTER="${DATE}${GITHUB_REF}"
elif [[ -z "${GITHUB_SHA}" ]]; then
GITHUB_SHA=$(git rev-parse --short HEAD)
FOOTER="${DATE} ✧ commit ${GITHUB_SHA}"
fi
SHA_RANGE="${GIT_COMMIT}"^.."${GIT_COMMIT}"
FOOTER=$(git --no-pager log --date=short --pretty="format:%ad ✧ commit %h%n" "${SHA_RANGE}")
MARK=$(git --no-pager log --date=short --pretty="format:%ad-%h%n" "${SHA_RANGE}")
URL=$(gh repo view --json url --jq '.url')/

# Docker command and arguments
ARGS="--rm -e TERM -e HOME=/data -u $(id -u):$(id -g) -v $(pwd):/data -w /data"
if [[ "$OSTYPE" == "darwin"* ]]; then
ARGS="$ARGS --platform linux/amd64"
fi
DRY_RUN=${IS_PR:-false}
if [[ "${DRY_RUN}" != "false" ]]; then
if [[ "${DRY_RUN}" == "true" ]]; then
DOCKER="echo docker"
elif [[ -z "${DOCKER}" ]]; then
DOCKER=docker
Expand Down Expand Up @@ -49,9 +49,10 @@ function to_pdf_with_changes() {
shift
rm -f "${pdfout}"

to_pdf --pdf-engine-opt=-output-dir="${tmpout}" \
--pdf-engine-opt=-outdir="${tmpout}" \
-o "${pdfout}" \
# Use mounted volume paths
to_pdf --pdf-engine-opt=-output-dir="./${tmpout}" \
--pdf-engine-opt=-outdir="./${tmpout}" \
-o "./${pdfout}" \
"$@"
}

Expand All @@ -67,6 +68,8 @@ function to_pdf() {
-V footer-left:"${FOOTER}" \
-V github:"${URL}blob/${GIT_COMMIT}/" \
"$@"

echo "$?"
}

mkdir -p output/tmp
Expand Down
1 change: 0 additions & 1 deletion .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,6 @@ jobs:
run: ./.github/docker-build-pdf.sh

- uses: actions/upload-artifact@v4
if: ${{ github.ref != 'refs/heads/main' }}
with:
name: pdf-output
path: output/public/*.pdf
Expand Down

0 comments on commit 6cf779c

Please sign in to comment.