This repository has been archived on 2021-07-22. You can view files and clone it, but cannot push or open issues or pull requests.
stack-ssh-deploy/plugin.sh

37 lines
765 B
Bash
Raw Normal View History

2020-09-25 10:43:54 +00:00
#!/bin/bash
set -e
2020-09-23 06:32:50 +00:00
PLUGIN_COMPOSE=${PLUGIN_COMPOSE:-compose.yml}
PLUGIN_HOST=${PLUGIN_HOST:-swarm.autonomic.zone}
PLUGIN_PORT=${PLUGIN_PORT:-222}
PLUGIN_USER=${PLUGIN_USER:-drone}
2020-09-23 06:50:38 +00:00
2020-09-23 06:35:16 +00:00
load_deploy_key() {
2020-09-23 07:24:15 +00:00
mkdir -p "$HOME/.ssh/"
ssh-keyscan -p "$PLUGIN_PORT" "$PLUGIN_HOST" > "$HOME/.ssh/known_hosts"
2020-09-23 07:24:15 +00:00
2020-09-25 10:44:00 +00:00
# shellcheck disable=SC2046,SC2006
2020-09-23 07:24:15 +00:00
eval `ssh-agent`
2020-09-23 07:00:55 +00:00
echo "$PLUGIN_DEPLOY_KEY" | ssh-add -
2020-09-23 06:32:50 +00:00
}
2020-09-23 06:35:16 +00:00
run_stack_deploy() {
2020-09-23 07:21:21 +00:00
echo "--- start docker info ---"
docker version
echo "--- end docker info ---"
docker \
-H "ssh://$PLUGIN_USER@$PLUGIN_HOST:$PLUGIN_PORT" \
stack deploy -c "$PLUGIN_COMPOSE" "$PLUGIN_STACK"
2020-09-23 06:32:50 +00:00
}
2020-09-23 06:35:16 +00:00
run_plugin() {
echo "--- start deployment ---"
2020-09-23 06:32:50 +00:00
load_deploy_key
run_stack_deploy
echo "--- end deployment ---"
2020-09-23 06:32:50 +00:00
}
run_plugin