Introduce workdir

This commit is contained in:
Lars Gohr
2019-09-23 20:37:32 +02:00
parent 42252004bb
commit 1b9fb052a2
3 changed files with 26 additions and 0 deletions

View File

@@ -71,6 +71,17 @@ with:
dockerfile: MyDockerFileName dockerfile: MyDockerFileName
``` ```
### workdir
Use `workdir` when you would like to change the directory for building.
```yaml
with:
name: myDocker/repository
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
workdir: mySubDirectory
```
### cache ### cache
Use `cache` when you have big images, that you would only like to build partially (changed layers). Use `cache` when you have big images, that you would only like to build partially (changed layers).
> CAUTION: This will cache the non changed parts forever. If you use this option, make sure that these parts will be updated by another job! > CAUTION: This will cache the non changed parts forever. If you use this option, make sure that these parts will be updated by another job!

View File

@@ -35,6 +35,10 @@ if [ $(echo ${GITHUB_REF} | sed -e "s/refs\/pull\///g") != ${GITHUB_REF} ]; then
BRANCH="pr$(echo ${GITHUB_REF} | sed -e "s/refs\/pull\///g" | sed -e "s/\///g")" BRANCH="pr$(echo ${GITHUB_REF} | sed -e "s/refs\/pull\///g" | sed -e "s/\///g")"
fi; fi;
if [ ! -z "${INPUT_WORKDIR}" ]; then
cd "${INPUT_WORKDIR}"
fi
echo ${INPUT_PASSWORD} | docker login -u ${INPUT_USERNAME} --password-stdin ${INPUT_REGISTRY} echo ${INPUT_PASSWORD} | docker login -u ${INPUT_USERNAME} --password-stdin ${INPUT_REGISTRY}
DOCKERNAME="${INPUT_NAME}:${BRANCH}" DOCKERNAME="${INPUT_NAME}:${BRANCH}"

View File

@@ -256,3 +256,14 @@ Called /usr/local/bin/docker logout"
[ "$status" -eq 1 ] [ "$status" -eq 1 ]
[ "$output" = "$expected" ] [ "$output" = "$expected" ]
} }
@test "it errors when the working directory is configured but not present" {
export INPUT_WORKDIR='mySubDir'
run /entrypoint.sh
local expected="/entrypoint.sh: cd: line 39: can't cd to mySubDir: No such file or directory"
echo "$output"
[ "$status" -eq 2 ]
[ "$output" = "$expected" ]
}