Skip to content

Commit

Permalink
Introduce workdir
Browse files Browse the repository at this point in the history
  • Loading branch information
Lars Gohr committed Sep 23, 2019
1 parent 4225200 commit 1b9fb05
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 0 deletions.
11 changes: 11 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,17 @@ with:
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
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!
Expand Down
4 changes: 4 additions & 0 deletions entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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")"
fi;

if [ ! -z "${INPUT_WORKDIR}" ]; then
cd "${INPUT_WORKDIR}"
fi

echo ${INPUT_PASSWORD} | docker login -u ${INPUT_USERNAME} --password-stdin ${INPUT_REGISTRY}

DOCKERNAME="${INPUT_NAME}:${BRANCH}"
Expand Down
11 changes: 11 additions & 0 deletions test.bats
Original file line number Diff line number Diff line change
Expand Up @@ -256,3 +256,14 @@ Called /usr/local/bin/docker logout"
[ "$status" -eq 1 ]
[ "$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" ]
}

0 comments on commit 1b9fb05

Please sign in to comment.