A GitHub Action to install the dprint code formatter, with caching for the binary and its WASM plugins.
uses: kjanat/install-dprint@v2{ uses: kjanat/install-dprint@v2, with: { version: 0.55.2 } }- uses: kjanat/install-dprint@v2
- run: dprint fmtOr combine it with autofix.ci
name: autofix.ci
on: { push: { branches: ["master"] }, pull_request: null }
permissions: { contents: read }
jobs:
autofix:
runs-on: ubuntu-latest
steps: [
uses: actions/checkout@v7,
uses: kjanat/install-dprint@v2,
# Optionally install other dependencies here, if using the `exec` plugin
# (or use exec's new `setupCommand` setting, see link in tip below).
{ run: dprint config update -yr, if: "${{ github.ref_name == 'master' }}" },
# or update your plugins:
run: dprint fmt --allow-no-files --diff --excludes .github,
# autofix-ci will fail if the .github directory is touched
uses: autofix-ci/action@v1,
]Tip
Use dprint-plugin-exec's new setupCommand for e.g. installing a formatter binary to add it to PATH.
More info: https://github.com/dprint/dprint-plugin-exec#configuration
| Name | Description | Default |
|---|---|---|
version |
dprint version to install (e.g. 0.55.2) |
latest |
cache |
Cache the dprint binary and WASM plugins via actions/cache |
true |
config-path |
Path or glob to dprint config file(s) for the plugin cache key (auto-detected if not set) | "" |
warmup |
Pre-download WASM plugins after a cache miss so the post step saves a complete store | true |
Config auto-detection deep-searches the workspace for .dprint.jsonc, .dprint.json, dprint.jsonc, dprint.json
(skipping node_modules and .git) and hashes every match into the cache key, so a monorepo's per-directory configs
all count; the root config is the primary. A config-path glob overrides detection.
| Name | Description |
|---|---|
version |
Installed dprint version |
location |
Path to the installed dprint binary |
cache-hit |
Whether the binary was restored from tool-cache or actions/cache |
plugin-cache-hit |
Whether the WASM plugin cache was restored (exact key match) |
plugin-cache-key |
The cache key used for the WASM plugin cache |
- The action exports
DPRINT_CACHE_DIR, pinning dprint's plugin store to one path on every OS, so the directory it caches is the directory dprint uses. - The plugin cache key hashes every matched config file plus the dprint version;
restore-keysfall back to the nearest older store. - The cache is saved in a post step that runs even when the job fails, so a failing
dprint checkstill warms the next run. - On a cache miss the action pre-downloads the plugins itself (bounded, with hang-detecting retries), keeping later dprint steps offline.