Created
February 1, 2018 16:23
-
-
Save cab404/3a055f1534132ec0adbe5da79eb56cf1 to your computer and use it in GitHub Desktop.
caching script for drone.io Volume Cache
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# drone.io cache simplifier by cab404, for using with Volume Cache plugin | |
# allows you to cache practically anything from anywhere, specifying only '.drone-cache' in mounts | |
# to pack something do "cache in (smthn)" | |
# to unpack all do "cache out" | |
# | |
# e.g you want to cache /root/.gradle/cache and /root/.gradle/wrapper (typical for android), you do | |
# get-cache: | |
# image: drillster/drone-volume-cache | |
# restore: true | |
# mount: | |
# - .drone-cache | |
# volumes: | |
# - /tmp/${DRONE_REPO}/cache:/cache | |
# | |
# build: | |
# commands: | |
# - ./cache out | |
# - somebuildcommand | |
# - ./cache in .gradle/cache | |
# - ./cache in .gradle/wrapper | |
# | |
# save-cache: | |
# image: drillster/drone-volume-cache | |
# rebuild: true | |
# mount: | |
# - .drone-cache | |
# volumes: | |
# - /tmp/${DRONE_REPO}/cache:/cache | |
CACHEDIR=.drone-cache | |
mkdir -p $CACHEDIR | |
if [ $1 == "in" ]; then | |
TARGET=$(readlink -f $2) | |
TARGETDIR=$(dirname $TARGET) | |
echo caching $TARGET | |
mkdir -p "$CACHEDIR$TARGETDIR" | |
cp -Tr "$TARGET" "$CACHEDIR$TARGET" | |
fi | |
if [ $1 == "out" ]; then | |
cp -Tr $CACHEDIR/ / | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment