Skip to content

Is it possible to share cache between github hosted and self-hosted runners? #1755

Open

Description

@Potabk

I‘d like to use a cache produced on a self-hosted runner on GitHub-hosted runner.

On my tests it didn't work even though their keys are exactly the same.

This is my cache build workflow,

Image

but in the verify workflow cache miss occurred despite even they have the exact same key.

Image

Is it possible to share cache between github hosted and self-hosted runners?
Thanks in advance

Activity

  1. Potabk commented on May 10, 2026

    @Potabk
    Author

    Found it, we should install zstd to keep consistent with ubuntu-latest

    We can find some evidence in the source code (tag=v4) that the compression method is decisive for the final cache result, with zstl being the preferred choice, followed by gzip. For different runners, if one has zstl installed (ubuntu-latest) while another does not (fallback to the gzip method), then the final cache versions they produce will be different. This also explains why a cache generated on a self-hosted runner cannot be used on ubuntu-latest (even if their keys are exactly the same).

    zstd available?
      ├── yes → CompressionMethod.ZstdWithoutLong  ("zstd-without-long")
      └── no → CompressionMethod.Gzip            ("gzip")
    const components = paths.slice();
    if (compressionMethod) {
        components.push(compressionMethod);  // ← "zstd-without-long" or "gzip"
    }
    // ...
    return crypto.createHash('sha256').update(components.join('|')).digest('hex');
    Scene Components of a hash Result
    Machines with zstd paths + "zstd-without-long" + salt → SHA256 hash A
    Machines without zstd paths + "gzip" + salt → SHA256 hash B
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions