Skip to main content
Browse documentation

CI and GitHub Actions

Enforce image freshness in CI

Make stale generated images fail pull-request checks before merge.

Pin the tool

Use an exact project dependency instead of a floating one-off download. The lockfile then selects the same CLI locally and in CI.

pnpm add --save-dev --save-exact @imageforge/cli@0.1.10

Add scripts

Keep build and check options identical.

{
  "scripts": {
    "images:build": "imageforge ./public/images -f webp,avif --widths 320,640,960,1280",
    "images:check": "imageforge ./public/images -f webp,avif --widths 320,640,960,1280 --check"
  }
}

Add the pull-request workflow

Commit the generated derivatives, imageforge.json, and .imageforge-cache.json with their source changes. A clean runner needs that complete baseline before --check can verify freshness.

The readable action tags below are a starting point. Replace them with reviewed full commit SHAs when your repository requires immutable workflow dependencies.

# .github/workflows/images.yml
name: Image freshness
on:
  pull_request:

permissions:
  contents: read

jobs:
  imageforge:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: pnpm/action-setup@v4
        with:
          version: 10
      - uses: actions/setup-node@v4
        with:
          node-version: 22
          cache: pnpm
      - run: pnpm install --frozen-lockfile
      - run: pnpm run images:check

Reproduce a failed check

A failed check prints a build command with the effective options. Review shell quoting for your terminal, regenerate, inspect the diff, and commit the refreshed state.

pnpm install --frozen-lockfile
pnpm run images:check