Drillster / drone-volume-cache

Drone plugin for caching to a locally mounted volume
MIT License
109 stars 43 forks source link

use a .cache_key file if present #21

Closed 3p3r closed 6 years ago

3p3r commented 6 years ago

I added an option to read the cache key from a .cache_key file if present. This works very similar to how .tags file works with the drone/docker plugin.

This way, user can generate the cache key dynamically and in other build steps (currently cache.sh only reads from environment variables which cannot be shared between steps).

I explained in details how it can be used in DOCS.md. I also added an option to skip sanitization (yaml key is cache_key_disable_sanitize: true).

This allows for a simulation of how CircleCI caching works. For example:

pipeline:
  make cache key:
    image: drillster/drone-volume-cache
    commands:
      - touch .cache_key
      - echo -n $(md5sum package.json)      >> .cache_key
      - echo -n $(md5sum package-lock.json) >> .cache_key
  restore cache:
    image: drillster/drone-volume-cache
    restore: true
    mount: [ node_modules ]
    volumes: [ '/tmp/cache:/cache' ]
mjwwit commented 6 years ago

Thanks for the PR! Sorry it took so long for me to review it. Looks good, I'll merge!