Skip to content

memospot/action-dagger

Repository files navigation

Dagger Action for GitHub

An alternate GitHub Action for running Dagger with better caching support.

This action is used in the memos-builds repository.

Important

This action is only for Linux runners.

Usage Examples

Basic Usage

- name: Run Dagger
  uses: memospot/action-dagger@v1
  with:
    module: github.com/shykes/daggerverse/hello
    call: hello --greeting Hola --name Jeremy

With Version Pinning

- name: Run Dagger with specific version
  uses: memospot/action-dagger@v1
  with:
    version: "0.19.11" # Pin to specific version
    module: github.com/shykes/daggerverse/hello
    call: hello

With Caching Disabled

- name: Run Dagger without caching
  uses: memospot/action-dagger@v1
  with:
    cache-builds: false
    module: github.com/shykes/daggerverse/hello
    call: hello

dagger shell

- name: Dagger Shell
  uses: memospot/action-dagger@v1
  with:
    shell: container | from alpine | with-exec echo,"hello, world!" | stdout

dagger run

- name: Integration Test
  uses: memospot/action-dagger@v1
  with:
    workdir: db-service
    verb: run
    args: node build.js

Inputs

Key Description Required Default
version Dagger CLI version (semver or 'latest') false latest
cache-builds Enable Dagger build cache persistence false true
cache-binary Cache Dagger binary to avoid re-downloading false true
cache-key Custom cache key (e.g. foo-${{ github.run_id }}) false
cache-mode Cache extraction mode (auto, direct, container) false auto
cache-timeout Timeout in minutes for cache save operations (0=disable) false "10"
dagger-flags Dagger CLI Flags false --progress plain
verb CLI verb (call, run, download, up, functions, shell, query) false call
workdir Working directory for Dagger CLI false .
cloud-token Dagger Cloud Token false
module Dagger module to call (local or Git) false
args Arguments to pass to CLI false
call Function and arguments for dagger call false
shell Function and arguments for dagger shell false
summary-path File path to write job summary false
enable-github-summary Write summary to GITHUB_STEP_SUMMARY false false

Outputs

Key Description
dagger-version The installed Dagger version
cache-hit Whether binary was restored from cache
binary-path Path to the installed Dagger binary
output Standard output of Dagger command
trace-url Dagger Cloud trace URL

Cache Strategy

Binary Cache

The Dagger binary is cached using GitHub Actions tool-cache by tool/version/arch lookup.

  • Tool name: dagger
  • Version: resolved Dagger version (including latest resolution)
  • Arch: runner architecture (for example amd64 or arm64)

Build Cache

Dagger build cache persists the engine state volume to GitHub Actions Cache:

Default Behavior: "Rolling cache" strategy.

  • Save Key: dagger-<arch>-<run_id> (always unique, forcing a save)
  • Restore Key: dagger-<arch>- (matches most recent previous run)

This ensures that every run saves its state on top of the previous one, maximizing cache freshness.

Custom Cache Keys

You can override the default key using cache-key. To maintain the recommended rolling cache behavior, ensure your key ends with a unique component like ${{ github.run_id }}.

- name: Run Dagger with custom key
  uses: memospot/action-dagger@v1
  with:
    cache-key: "my-project-v2-${{ runner.os }}-${{ github.run_id }}"
    module: github.com/shykes/daggerverse/hello
    call: hello

The action will automatically derive the restore key by stripping the last hyphen-delimited segment (e.g., my-project-v2-${{ runner.os }}).

Cache Invalidation

To invalidate the cache, simply change the prefix of your cache-key (e.g., from v1 to v2). If using defaults, the action handles versioning internally.

Cache Modes

The cache-mode input controls how the Dagger engine state is cached:

  • auto (default): Automatically tries direct mode first, then falls back to container if it fails.
  • direct: Uses direct volume mounting for faster cache operations. May encounter permission issues on some runners.
  • container: Uses a busybox container to create/restore tarballs. Slower and with higher disk usage peak, but more reliable.

Cache failures in any mode are soft-failures - the action will emit a warning but continue execution.

- name: Run Dagger with explicit cache mode
  uses: memospot/action-dagger@v1
  with:
    cache-mode: direct
    module: github.com/shykes/daggerverse/hello
    call: hello

Migration Guide

  1. Update your workflow:

    # Before
    uses: dagger/dagger-for-github@v7
    
    # After
    uses: memospot/action-dagger@v1
  2. New features available:

    • Binary caching: cache-binary: true
    • Build caching: cache-builds: true
    • Version output: ${{ steps.dagger.outputs.dagger-version }}
  3. Backward compatibility: Existing inputs continue to work

Contributing

See CONTRIBUTING.md for development setup, project structure, and release process.

About

Enhanced Dagger GitHub Action

Resources

Contributing

Security policy

Stars

Watchers

Forks

Releases

Packages

Used by

Contributors

Languages