27 lines
1.2 KiB
Bash
Executable File
27 lines
1.2 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
# Usage: dashboard/packaging/werkregie-deploy
|
|
#
|
|
# The buildCommand of Werkator's build "deploy", which follows a green build of main.
|
|
# It builds the runtime bundle of the tested commit and hands it to werkregie-deploy-receive,
|
|
# the forced command of the deploy key on the server.
|
|
# Where the server is and which key opens it, the host says in the ssh configuration of the build's home,
|
|
# as the alias werkregie-deploy, so that the build works natively and in the sandbox alike;
|
|
# DEPLOY_TARGET overrides the alias.
|
|
# One connection carries the bundle and the answer, since Hostsharing refuses connections that follow too quickly;
|
|
# a refused one is tried again (werkrevisor PR#70).
|
|
set -euo pipefail
|
|
target="${DEPLOY_TARGET:-werkregie-deploy}"
|
|
|
|
cd "$(dirname "$0")/.."
|
|
./gradlew --console=plain --no-daemon runtimeBundle
|
|
bundle=build/distributions/werkregie-dashboard-runtime-linux-x64.tar.gz
|
|
|
|
for attempt in 1 2 3 4; do
|
|
status=0
|
|
ssh -T -o BatchMode=yes "$target" < "$bundle" || status=$?
|
|
# 255 is ssh's own failure, e.g. a refused connection; any other status is the receiver's
|
|
[[ $status -eq 255 && $attempt -lt 4 ]] || exit $status
|
|
echo "connection failed, retry in $((30 * attempt)) s" >&2
|
|
sleep $((30 * attempt))
|
|
done
|