Screenshot automation in CI
Create CI screenshots without a browser on the runner
Use the Scrnify CLI as a normal shell command. The hosted Capture service loads the public URL; your runner receives one asset URL and downloads the file for its next step.
set -euo pipefail
capture_url="$(scrnify capture "$TARGET_URL" \
--type image --format png \
--width 1440 --height 900)"
curl -fsSL "$capture_url" -o ci-screenshot.png
test -s ci-screenshot.pngShell contract
Success: asset URL on stdout and exit 0. Usage/config errors exit 1; API, HTTP, and network errors exit 2.
Run sheet
Treat capture like any other shell dependency
- 01
Install the CLI
Homebrew installs scrnify on macOS. Release archives are published for macOS and Linux on amd64 and arm64. Pin or record the version when reproducible CI tooling matters.
- 02
Inject secrets
Store SCRNIFY_API_KEY in the CI provider’s secret store. Do not put the key in repository YAML, a target URL, or echoed diagnostic output.
- 03
Fail on capture errors
Capture stdout into a shell variable. With fail-fast shell behavior, a non-zero scrnify exit stops the step; curl -f also rejects failed download responses.
- 04
Publish with your provider
Pass ci-screenshot.png to the provider’s artifact command or Action. Scrnify creates the Capture; it does not upload files into your CI run by itself.
Before sharing
Keep automation deterministic
- Set width and height for viewport captures, or use --full-page when page length is the evidence you need.
- Use --wait-until networkIdle only when that lifecycle event matches how the target finishes loading.
- Check the downloaded file is non-empty before publishing it as an artifact.
- Read stderr and exit code on failure; stdout is reserved for the successful asset URL.