Way to read file content as part of cache key


#1

I am storing a cache with a date stamped version if an exact checksum misses:

      - run:
          name: datestamps
          command: |
            date '+%Y' > ~/YEAR
            date '+%Y-%m' > ~/MONTH
            date '+%Y-%W' > ~/WEEK
      - restore_cache:
          keys:
            - v1-checksum-{{ checksum "build.boot" }}
            - v1-week-{{ checksum "~/WEEK" }}
      - run: boot deps
      - save_cache:
          paths:
            - ~/.m2
          key: v1-checksum-{{ checksum "build.boot" }}
      - save_cache:
          paths:
            - ~/.m2
          key: v1-week-{{ checksum "~/WEEK }}

It would be nice if I could use the file content of ~/WEEK directly in the cache key, rather than the checksum of it. This would make debugging easier, and also let me easily do a week/month/year hierarchy for restoring the cache. Is this possible? I can see there are some functions and templates available for cache keys, but I couldn’t see one for reading a file. Is this possible?


#2

This topic was automatically closed 41 days after the last reply. New replies are no longer allowed.