From 3fde5ef21a797bfe4d73bcf588a3ac0a1e5df14b Mon Sep 17 00:00:00 2001 From: cellarspoon Date: Tue, 4 Jan 2022 14:49:01 +0100 Subject: [PATCH] attempt to support private registries --- README.md | 2 ++ plugin.sh | 9 ++++++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index d1258c1..c1c9dfa 100644 --- a/README.md +++ b/README.md @@ -21,6 +21,8 @@ This is meant to be used as a [Drone plugin](http://plugins.drone.io/). - **user** (default: `drone`): System user to connect via SSH with - **networks** (default:): Try and auto-create these networks first - **rm**: (default: `false`): Remove the stack before deploying it +- **reg_user**: Registry user if publishing from a private repository +- **reg_pass**: Registry password if publishing from a private repository ### Dangerous options, unwise outside CI diff --git a/plugin.sh b/plugin.sh index 0544c5b..b17b43f 100755 --- a/plugin.sh +++ b/plugin.sh @@ -63,7 +63,14 @@ output_versions(){ run_stack_deploy() { echo "--- start deploy ---" - docker -H "$REMOTE_DOCKER_HOST" stack deploy -c "$PLUGIN_COMPOSE" "$PLUGIN_STACK" + + if [[ -z "${PLUGIN_REG_USER}" ]] && [[ -z "${PLUGIN_REG_PASS}" ]]; then + echo "--- discovered secrets, assuming private registry, logging in ---" + docker login -u "${PLUGIN_REG_USER}" -p "${PLUGIN_REG_PASS}" + docker -H "$REMOTE_DOCKER_HOST" stack deploy -c "$PLUGIN_COMPOSE" "$PLUGIN_STACK" + else + docker -H "$REMOTE_DOCKER_HOST" stack deploy -c "$PLUGIN_COMPOSE" "$PLUGIN_STACK" + fi echo "--- end deploy ---" }