How to properly cache GO dependency, specifically SOPS?

I’m currently using sops in GitHub Actions by installing it via

- name: Install sops
  run: go get -u go.mozilla.org/sops/v3/cmd/sops

And have tried to cache them via GitHub Actions Cache for Go

- name: Cache SOPS
  uses: actions/cache@v2
  with:
    path: ~/go/pkg/mod
    key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
    restore-keys: |
      ${{ runner.os }}-go-

It receives the cache

Cache Size: ~0 MB (22 B)
/bin/tar --use-compress-program zstd -d -xf /home/runner/work/_temp/ff3117ba-d412-4ddd-a7c4-b3e259d069c2/cache.tzst -P -C /home/runner/work/projectName/projectName
Cache restored from key: Linux-go-

But still, installs the sops from scratch, maybe this should be cached somehow differently?

@Dwite ,

Looks like, when you saved the cache, you did not specify the correct path where the package sops was actually installed. The sops seems was not installed in the directory “~/go/pkg/mod”, and this directory was empty.

Note: when you use the cache action to save dependencies, if the specified path is existing but empty, the cache action will still execute and not return any error, it will save an empty cache.

Before you save the dependencies, make sure you have specified the correct installation directory of the dependencies.