Marp GitHub Action To Build The Presentation Files

I had problems getting some of the presentation files to generate on some platforms. I decided to put together this GitHub action to automate this process.

Add the following code to a file called something like ".github/workflows/workflow.yml".

name: Marp Workflow

on:
  push:
    branches:
      - master
      - main

jobs:
  publish:
    runs-on: ubuntu-latest
    permissions:
      contents: write
    steps:
      - name: Check out repository code.
        uses: actions/checkout@v4

      - name: Install Node.js
        uses: actions/setup-node@v4
        with:
          cache: npm
          node-version-file: '.nvmrc'

      - name: Install dependencies
        run: npm ci

      - name: Build Marp slide deck
        run: CHROME_PATH=$(npx -y @puppeteer/browsers@latest install chrome@stable --path $(realpath ./tmp) | awk '{print $2}') npm run build:all

      - uses: actions/upload-artifact@v4
        with:
          name: slides
          path: |
            dist/*.pdf
            dist/*.pptx

      - name: Update username config.
        run: git config --local user.name "github-actions[bot]"
        
      - name: Update the user email config. 
        run: git config --local user.email "github-actions[bot]@users.noreply.github.com"

      - name: Stage changed files.
        run: git add dist/*

      - name: Commit changed files.
        run: git commit -m "Auto updating presentation files."

      - name: Push code to main
        run: git push origin main

Note that the command I use to generate all the Marp file formats is "npm run build:all", which is from my Marp talk template repository. You can see this workflow in action in that repository. Change this to suit your needs.

The node system requires a file called .nvmrc to be created in the root of your repository. This should just contain the version of node you want to use. For example:

20.11.1

Commit this to the repository and push this to GitHub. This will generate the HTML, PDF, and PPTX files in the dist directory and commit them. It will also add the PDF and PPTX files as artifacts in a file called "slides.zip" that you can then distribute.

Add new comment

The content of this field is kept private and will not be shown publicly.
CAPTCHA
15 + 1 =
Solve this simple math problem and enter the result. E.g. for 1+3, enter 4.
This question is for testing whether or not you are a human visitor and to prevent automated spam submissions.