DeterminateSystems / magic-nix-cache-action

Save 30-50%+ of CI time without any effort or cost. Use Magic Nix Cache, a totally free and zero-configuration binary cache for Nix on GitHub Actions.
MIT License
389 stars 15 forks source link

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

Open icewind1991 opened 1 year ago

icewind1991 commented 1 year ago

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.

phated commented 1 year ago

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