add support of CI_REPO_NAME
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful

This commit is contained in:
Dmitriy Pleshevskiy 2023-03-15 12:32:36 +03:00
parent d9c19b42fd
commit 4c632b99f8
Signed by: pleshevskiy
GPG key ID: 79C4487B44403985
2 changed files with 21 additions and 15 deletions

View file

@ -7,8 +7,8 @@ Simple bash plugin to login and stack deploy
## Options
| property | type | default | description |
| ----------------- | ------ | ------------------ | ----------------------------------------- |
| name | string | $DRONE_REPO_NAME | Stack name |
| ----------------- | ------ | -------------------------------- | ----------------------------------------- |
| 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 |

View file

@ -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}"