appleboy / drone-sftp-cache

Drone plugin for caching artifacts to a central server using sftp
Apache License 2.0
13 stars 12 forks source link

Issue with branch names when using git tag #10

Open kushtrimjunuzi opened 7 years ago

kushtrimjunuzi commented 7 years ago

The issue is that this plugin creates a hash file name based on branch name and mount path and every time you git tag you will have new cache file. DRONE_BRANCH and DRONE_TAG are the same at least for bitbucket.org. I saw the commented code that handles fallback when there is no cache file it takes from master by default and that is as a DRONE_REPO_BRANCH. So my question is can we handle this situation by using DRONE_REPO_BRANCH value as fallback?

dvmorris commented 7 years ago

@kushtrimjunuzi we are running into the same issue. Did you have any luck making a change to fix this?

kushtrimjunuzi commented 7 years ago

@dvmorris merge with my pull request, I know there are few other nice changes and also this one is at the last commit, take a look at this one https://github.com/drone-plugins/drone-sftp-cache/pull/6/commits/40283f561c4ff2133e904e56af6bab5745ce1cee

appleboy commented 7 years ago

@kushtrimjunuzi I add IgnoreBranch flag for ignoring branch name.

Try the following config.

  # restore the cache from an sftp server
  restore_cache:
    image: appleboy/drone-sftp-cache
    restore: true
    mount: [ cache, node_modules, .yarn-cache ]
    ignore_branch: true

see https://github.com/appleboy/drone-sftp-cache/commit/04a39b7e38547331ff0a9f3e152c2e0e8612524e

jvican commented 7 years ago

It may be interesting to add this to the docs. It's not clear that ignore_branch has an effect on the cache of tags :smile:. I confirm that adding it allowed me to reuse Drone's cache for my first tag release.

appleboy commented 7 years ago

I have added this to the docs. see https://github.com/appleboy/drone-sftp-cache/blob/master/DOCS.md or feel free to open pull request.