diff --git a/README.md b/README.md index 8d84498..c40d33d 100644 --- a/README.md +++ b/README.md @@ -6,10 +6,10 @@ Simple bash plugin to login and stack deploy ## Options -| property | type | default | description | -| ----------------- | ------ | ------------------ | ----------------------------------------- | -| name | string | $DRONE_REPO_NAME | Stack name | -| compose_file_path | string | docker-compose.yml | Path to your docker compose configuration | -| registry | string | $ORG_REGISTRY | Authenticates to this registry | -| username | string | | Authenticates with this username | -| password | string | | Authenticates with this password | +| property | type | default | description | +| ----------------- | ------ | -------------------------------- | ----------------------------------------- | +| name | string | $DRONE_REPO_NAME / $CI_REPO_NAME | Stack name | +| compose_file_path | string | docker-compose.yml | Path to your docker compose configuration | +| registry | string | $ORG_REGISTRY | Authenticates to this registry | +| username | string | | Authenticates with this username | +| password | string | | Authenticates with this password | diff --git a/entrypoint.sh b/entrypoint.sh index e09daaf..93e36bb 100644 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -1,9 +1,15 @@ #!/bin/sh -set -ex +set -e -if [ -n "${PLUGIN_REGISTRY:-$ORG_REGISTRY}" ]; then - AUTH_FLAGS=--with-registry-auth +registry="${PLUGIN_REGISTRY:-$ORG_REGISTRY}" +stack_name="${PLUGIN_NAME:-${DRONE_REPO_NAME:-${CI_REPO_NAME}}}" +compose_file="${PLUGIN_COMPOSE_FILE_PATH:-docker-compose.yml}" + +set -x + +if [ -n "${registry}" ]; then + auth_flags=--with-registry-auth fi if [ -n "$PLUGIN_PASSWORD" ]; then @@ -11,11 +17,11 @@ if [ -n "$PLUGIN_PASSWORD" ]; then docker login \ -u "$PLUGIN_USERNAME" \ --password-stdin \ - ${PLUGIN_REGISTRY:-$ORG_REGISTRY} + ${registry} fi -docker stack deploy \ - $AUTH_FLAGS \ - -c "${PLUGIN_COMPOSE_FILE_PATH:-docker-compose.yml}" \ - "${PLUGIN_NAME:-$DRONE_REPO_NAME}" +docker stack deploy + $auth_flags \ + --compose-file "${compose_file}" \ + "${stack_name}"