From 6cf779c704ca771dfde1b138818152d2619ed06d Mon Sep 17 00:00:00 2001 From: Erin Schnabel Date: Mon, 29 Jan 2024 17:20:39 -0500 Subject: [PATCH] Use mounted volume path for generated pdfs --- .github/docker-build-pdf.sh | 23 +++++++++++++---------- .github/workflows/build.yaml | 1 - 2 files changed, 13 insertions(+), 11 deletions(-) diff --git a/.github/docker-build-pdf.sh b/.github/docker-build-pdf.sh index 86bcbac..d6ca357 100755 --- a/.github/docker-build-pdf.sh +++ b/.github/docker-build-pdf.sh @@ -5,12 +5,13 @@ 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 @@ -18,8 +19,7 @@ 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 @@ -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}" \ "$@" } @@ -67,6 +68,8 @@ function to_pdf() { -V footer-left:"${FOOTER}" \ -V github:"${URL}blob/${GIT_COMMIT}/" \ "$@" + + echo "$?" } mkdir -p output/tmp diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index ef4ca73..66efb50 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -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