stack-ssh-deploy/plugin.sh
Luke Murphy 7c11311f02
All checks were successful
continuous-integration/drone/push Build is passing
Add port and drop ssh:// from user side
2020-09-23 09:31:36 +02:00

33 lines
628 B
Bash
Executable File

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