hashFiles not behaving as expected

I am trying to cache a file, and run hashFiles against that file but hashFiles seems to always return an empty string - perhaps I am using it incorrectly?

      - name: Cache sitemap.xml
        id: cache
        uses: actions/cache@v2
          path: ~/src/sitemap.xml
          key: ${{ runner.os }}-sitemap-${{ hashFiles('**/sitemap.xml') }}

When I look in the build log, I always see this:

Run actions/cache@v2
    path: ~/src/sitemap.xml
    key: Linux-sitemap-

I keep expecting to see a hash of some sort at the end of the key…
Any help would be appreciated!

Maybe it’s an issue with the paths?


The path is relative to the GITHUB_WORKSPACE directory and can only include files inside of the GITHUB_WORKSPACE

You could try this for debugging:

run: |
  realpath ~/src/sitemap.xml