From c509dbd9e4eed93fe13f85ae474d52542652c081 Mon Sep 17 00:00:00 2001
From: Martin Geisler <mgeisler@google.com>
Date: Mon, 4 Mar 2024 16:25:58 +0100
Subject: [PATCH] Always install and run `mdbook-pandoc` (#1713)
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Before, we only installed and ran `mdbook-pandoc` when publishing the
course — which means that a PR change could accidentally break the
publish workflow. We now test that it works on every PR.

From a discussion in #1704.
---
 .github/workflows/build.sh                  | 4 +---
 .github/workflows/install-mdbook/action.yml | 8 ++++++++
 .github/workflows/publish.yml               | 7 -------
 3 files changed, 9 insertions(+), 10 deletions(-)

diff --git a/.github/workflows/build.sh b/.github/workflows/build.sh
index 8df3cc459c40..75cef84afce6 100755
--- a/.github/workflows/build.sh
+++ b/.github/workflows/build.sh
@@ -37,9 +37,7 @@ else
 fi
 
 mdbook build -d "$dest_dir"
-if [ -f "$dest_dir/pandoc/pdf/comprehensive-rust.pdf" ]; then
-    mv "$dest_dir/pandoc/pdf/comprehensive-rust.pdf" "$dest_dir/html/"
-fi
+mv "$dest_dir/pandoc/pdf/comprehensive-rust.pdf" "$dest_dir/html/"
 (cd "$dest_dir/exerciser" && zip --recurse-paths ../html/comprehensive-rust-exercises.zip comprehensive-rust-exercises/)
 
 echo "::endgroup::"
diff --git a/.github/workflows/install-mdbook/action.yml b/.github/workflows/install-mdbook/action.yml
index caf23fdfa84b..48026a515d32 100644
--- a/.github/workflows/install-mdbook/action.yml
+++ b/.github/workflows/install-mdbook/action.yml
@@ -15,6 +15,14 @@ runs:
       run: cargo install mdbook-svgbob --locked --version 0.2.1
       shell: bash
 
+    - name: Install mdbook-pandoc and related dependencies
+      run: |
+        cargo install mdbook-pandoc --locked --version 0.5.0
+        sudo apt-get install -y texlive texlive-luatex texlive-lang-cjk librsvg2-bin fonts-noto
+        curl -LsSf https://github.com/jgm/pandoc/releases/download/3.1.11/pandoc-3.1.11-linux-amd64.tar.gz | tar zxf -
+        echo "$PWD/pandoc-3.1.11/bin" >> $GITHUB_PATH
+      shell: bash
+
     - name: Install mdbook-i18n-helpers
       run: cargo install mdbook-i18n-helpers --locked --version 0.3.1
       shell: bash
diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml
index 28d04b7d8764..0f8d46d6f115 100644
--- a/.github/workflows/publish.yml
+++ b/.github/workflows/publish.yml
@@ -39,13 +39,6 @@ jobs:
       - name: Install mdbook
         uses: ./.github/workflows/install-mdbook
 
-      - name: Install mdbook-pandoc and related dependencies
-        run: |
-          cargo install mdbook-pandoc --locked --version 0.5.0
-          sudo apt-get install -y texlive texlive-luatex texlive-lang-cjk librsvg2-bin fonts-noto
-          curl -LsSf https://github.com/jgm/pandoc/releases/download/3.1.11/pandoc-3.1.11-linux-amd64.tar.gz | tar zxf -
-          echo "$PWD/pandoc-3.1.11/bin" >> $GITHUB_PATH
-
       - name: Build course in English
         run: .github/workflows/build.sh en book