snapcode

CI recipes

CI recipes

Render README and docs images automatically in a pipeline. The CLI runs fully offline, so no secrets are needed for watermarked output; add a Pro API key as a secret to render unbranded with your saved themes.

GitHub Action: re-render README snippets on push

.github/workflows/docs-images.yml
name: docs-images
on:
  push:
    paths: ["examples/**"]

jobs:
  render:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: actions/setup-node@v4
        with:
          node-version: 20
      - run: npm i -g snapcode
      - name: Render README snippets
        run: |
          snapcode generate --file examples/quickstart.ts \
            --theme github-dark --bg midnight \
            --title quickstart.ts --out docs/assets/hero.png
      - name: Commit updated images
        uses: stefanzweifel/git-auto-commit-action@v5
        with:
          commit_message: "chore: re-render README snippets"
          file_pattern: "docs/assets/*.png"

Keep the rendered PNGs in docs/assets/ and reference them from README.md. The action commits updated images only when the source files change.

Local: render before committing

snapcode generate --file examples/quickstart.ts --theme github-dark --out docs/assets/hero.png

As a pre-commit hook or npm script, same command:

For unbranded CI output, create an API key in the dashboard, add it as the SNAPCODE_API_KEY secret, and replace the generate line with a curl to the render API (see Render API above) — or run snapcode login on a self-hosted runner.