magic-nix-cache-action icon indicating copy to clipboard operation
magic-nix-cache-action copied to clipboard

Allow only using the magic-nix-cache is a secret isn't set

Open icewind1991 opened this issue 2 years ago • 1 comments

I already have a external nix cache for actions which works great but can't be used by external PR's/forks.

magic-nix-cache does work for forks but doesn't do cross-branch caching and can hit github's rate limits.

Ideally I would configure my action to use the external cache for any job that has access to the required secrets and fallback to magic-nix-cache for any job that doesn't.

I could just always enable the magic-nix-cache but it seems wasteful to put extra load on github's cache when the external cache is available. It is also possible to make steps conditional based on the availability of secrets, it's a bit cumbersome requires more boilerplate that I would like to have to repeat for every job.

It would be nice the the magic-nix-cache action has a builtin option to check for the availability of secrets and disable itself when the secret is set. Something like:

steps:
  - uses: DeterminateSystems/magic-nix-cache-action@main
    with:
      skipIf: ${{ secrets.ATTIC_TOKEN }}

would make it easy to get a "best of both worlds" caching setup with minimal boilerplate.

icewind1991 avatar Jul 08 '23 12:07 icewind1991

why can't you use if: on your step?

phated avatar Jul 09 '23 23:07 phated