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.
Update 09/02/2025:
Due to recent changes with Chrome and Puppeteer you will need to set some environment variables to prevent errors to do with sandbox mode in Chrome and Puppeteer timing out.
Add the following lines before the build step for Marp.
- name: Set envivonment var for chrome sandbox
run: echo "CHROME_NO_SANDBOX=1" >> $GITHUB_ENV
- name: Test chrome environment var
run: echo $CHROME_NO_SANDBOX
- name: Set envivonment for puppeteer timeout
run: echo "PUPPETEER_TIMEOUT=0" >> $GITHUB_ENV
- name: Test puppet environment var
run: echo $PUPPETEER_TIMEOUT
The timeouts are especially the case when generating PDF slides.
Add new comment