diff --git a/README.md b/README.md index 879119a..f834c5e 100644 --- a/README.md +++ b/README.md @@ -16,6 +16,7 @@ Clone a commit: ``` docker run --rm \ + -e DRONE_WORKSPACE=/drone \ -e DRONE_REMOTE_URL=https://github.com/drone/envsubst.git \ -e DRONE_BUILD_EVENT=push \ -e DRONE_COMMIT_SHA=15e3f9b7e16332eee3bbdff9ef31f95d23c5da2c \ diff --git a/posix/clone b/posix/clone index 93e9a0e..08b6160 100755 --- a/posix/clone +++ b/posix/clone @@ -1,29 +1,28 @@ #!/bin/sh -if [[ ! -z "${DRONE_WORKSPACE}" ]]; then - if [[ -n "${CI}" ]]; then - sudo mkdir -p ${DRONE_WORKSPACE} - sudo chown drone:drone ${DRONE_WORKSPACE} - else - mkdir -p ${DRONE_WORKSPACE} - fi +if [[ -n "${DRONE_WORKSPACE}" ]]; then + echo "[DEBUG] creating drone workspace" + + # ensure the unprivileged drone user can write + # to the workspace. This is required because + # the workspace is a docker volume and is owned + # by root. + sudo mkdir -p ${DRONE_WORKSPACE} + sudo chown drone:drone ${DRONE_WORKSPACE} + + # ensure the workspace is the current working + # directory. This should already be the case, + # but we cd just to be safe. cd ${DRONE_WORKSPACE} fi -# we default home directory to /home/drone +# force the home directory path. if [ "$HOME" != "/home/drone" ]; then + echo "[DEBUG] setting default home directory" export HOME=/home/drone fi -# if the home directory does not exist it should -# be created. - -if [ ! -d "${HOME}" ]; then - echo "HOME directory does not exist; creating ${HOME}" - mkdir -p ${HOME} -fi - # if the netrc enviornment variables exist, write # the netrc file.