Caching based on the checksum of a directory's contents

Inspired by a couple questions here, I wrote up a way to cache key based on your directories contents using md5sum. Hope it helps. (I’m sure there is a way to do this cleaner too)

      - run: |
          echo $(find ./migrations -type f -exec md5sum {} \; | md5sum | cut -d' ' -f1)  >> CACHE_KEY1
      - run: cat CACHE_KEY1
      - save_cache:
          key: test-cache-v1-{{ checksum "CACHE_KEY1" }}
            - migrations


This didn’t seem to work for me, I get a different key with the same directory contents.

Checksum different before and after bundle install - #11 by PADomine or Caching Dependencies - CircleCI may address the issue you encountered @abe.