Add port and drop ssh:// from user side
continuous-integration/drone/push Build is passing Details

This commit is contained in:
Luke Murphy 2020-09-23 09:31:36 +02:00
parent 13b37ce16d
commit 7c11311f02
No known key found for this signature in database
GPG Key ID: 5E2EF5A63E3718CC
2 changed files with 10 additions and 6 deletions

View File

@ -10,7 +10,8 @@ This is meant to be used as a [Drone plugin](http://plugins.drone.io/).
- **stack**: Name of the stack to be deployed
- **compose** (default: `compose.yml`): compose file to use for deploying
- **host**: SSH-based docker daemon context to deploy against
- **host**: SSH-based docker daemon context to deploy against (don't include `ssh://`)
- **port** (default: `22`): SSH port to connect to
- **deploy_key**: SSH private key part for ssh public key authentication
## Example
@ -24,7 +25,8 @@ steps:
image: decentral1se/stack-ssh-deploy:0.0.1
settings:
stack: mystack
host: "ssh://drone@swarm.autonomic.zone:222"
host: "drone@swarm.autonomic.zone"
port: 222
deploy_key:
from_secret: drone_deploy_key
```

View File

@ -1,22 +1,24 @@
#!/bin/sh
PLUGIN_PORT=${PLUGIN_PORT:-22}
PLUGIN_COMPOSE=${PLUGIN_COMPOSE:-compose.yml}
load_deploy_key() {
mkdir -p "$HOME/.ssh/"
ssh-keyscan "$PLUGIN_HOST" > "$HOME/.ssh/known_hosts"
ssh-keyscan -p "$PLUGIN_PORT" "$PLUGIN_HOST" > "$HOME/.ssh/known_hosts"
eval `ssh-agent`
echo "$PLUGIN_DEPLOY_KEY" | ssh-add -
}
run_stack_deploy() {
PLUGIN_COMPOSE=${PLUGIN_COMPOSE:-compose.yml}
echo "--- start docker info ---"
docker version
echo "--- end docker info ---"
docker -H "$PLUGIN_HOST" stack deploy -c "$PLUGIN_COMPOSE" "$PLUGIN_STACK"
docker \
-H "ssh://$PLUGIN_HOST:$PLUGIN_PORT" \
stack deploy -c "$PLUGIN_COMPOSE" "$PLUGIN_STACK"
}
run_plugin() {