Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change behaviour of NO_PUSH to be boolean #107

Merged
merged 7 commits into from
Dec 4, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ See the [examples](#examples) section is very helpful for understanding the inpu
- **`ADDITIONAL_TAG`**:
An optional string that specifies the name of an additional tag you would like to apply to the image. Images are already tagged with the relevant [GitHub commit SHA](https://help.github.com/en/github/getting-started-with-github/github-glossary#commit).
- **`NO_PUSH`**:
Setting this variable to any value will prevent any images from being pushed to a registry. Furthermore, verbose logging will be enabled in this mode. This is disabled by default.
If "true". this variable will prevent any images from being pushed to a registry. Furthermore, verbose logging will be enabled in this mode. Default value is "false".
- **`BINDER_CACHE`**:
Setting this variable to any value will add the file `binder/Dockerfile` that references the docker image that was pushed to the registry by this Action. You cannot use this option if the parameter `NO_PUSH` is set. This is disabled by default.
- Note: This Action assumes you are not explicitly using Binder to build your dependencies (You are using this Action to build your dependencies). If a directory `binder` with other files other than `Dockerfile` or a directory named `.binder/` is detected, this step will be aborted. This Action does not support caching images for Binder where dependencies are defined in `binder/Dockerfile` (if you are defining your dependencies this way, you probably don't need this Action).
Expand Down Expand Up @@ -561,7 +561,7 @@ jobs:

## Test Image Build

You might want to only test the image build withtout pushing to a registry, for example to test a pull request. You can do this by specifying any value for the `NO_PUSH` parameter:
You might want to only test the image build withtout pushing to a registry, for example to test a pull request. You can do this by setting the `NO_PUSH` parameter to 'true':

```yaml
name: Build Notebook Container
Expand Down
14 changes: 12 additions & 2 deletions create_docker_image.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,13 @@ if [ "$INPUT_APPENDIX_FILE" ]; then
echo "Appendix read from $INPUT_APPENDIX_FILE:\n$APPENDIX"
fi

# Set INPUT_NO_PUSH to false if it is not provided
if [ -z "$INPUT_NO_PUSH" ]; then
INPUT_NO_PUSH="false"
fi

# Login to Docker registry if about to push and credentials are passed
if [[ -z "$INPUT_NO_PUSH" && -n "$INPUT_DOCKER_PASSWORD" && -n "$INPUT_DOCKER_USERNAME" ]]; then
if [[ "$INPUT_NO_PUSH" = "false" && -n "$INPUT_DOCKER_PASSWORD" && -n "$INPUT_DOCKER_USERNAME" ]]; then
echo ${INPUT_DOCKER_PASSWORD} | docker login $INPUT_DOCKER_REGISTRY -u ${INPUT_DOCKER_USERNAME} --password-stdin
fi

Expand Down Expand Up @@ -165,7 +170,7 @@ if [ -d "${PWD}/image-tests" ]; then
echo "::endgroup::"
fi

if [ -z "$INPUT_NO_PUSH" ]; then
if [ "$INPUT_NO_PUSH" = "false" ]; then
echo "::group::Pushing ${SHA_NAME}"

docker push ${SHA_NAME}
Expand Down Expand Up @@ -194,6 +199,11 @@ if [ -z "$INPUT_NO_PUSH" ]; then
fi

else
if [ "$INPUT_NO_PUSH" != "true" ]; then
echo "Error: invalid value for NO_PUSH: $INPUT_NO_PUSH. Valid values are true or false."
exit 1
fi

echo "PUSH_STATUS=false" >> $GITHUB_OUTPUT
fi

Expand Down
Loading