mirror of
https://github.com/elgohr/Publish-Docker-Github-Action.git
synced 2026-03-12 18:07:12 -04:00
Introduce workdir
This commit is contained in:
11
README.md
11
README.md
@@ -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!
|
||||||
|
|||||||
@@ -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}"
|
||||||
|
|||||||
11
test.bats
11
test.bats
@@ -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" ]
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user