Commit 3a49c6c4 authored by Georges Racinet's avatar Georges Racinet 🌳
Browse files

Heptapod CI/CD: split out push script for reuse

--HG--
branch : heptapod-stable
parent a623efe9f792
Pipeline #14084 skipped with stages
......@@ -25,22 +25,9 @@ hg archive -t tgz ${TARBALL_PATH}
sha256sum ${TARBALL_PATH} > ${TARBALL_PATH}.sha256sum
if [ -n "$HEPTAPOD_TARBALL_UPLOAD_KEY" ]; then
HEPTAPOD_DOWNLOAD_SITE=download.heptapod.net
echo "Pushing ${TARBALL} to ${HEPTAPOD_DOWNLOAD_SITE} via SFTP"
KNOWN_HOSTS=$(realpath $(dirname $0)/heptapod_known_hosts.ssh)
SSH_FLAGS="-o IdentitiesOnly=yes -o UserKnownHostsFile=${KNOWN_HOSTS}"
if [ -n "$HEPTAPOD_UPLOAD_SSH_PORT" ]; then
SSH_FLAGS="$SSH_FLAGS -P $HEPTAPOD_UPLOAD_SSH_PORT"
fi
# TODO it would be nice of the runner to set restrictive permissions
# this right at file creation time (perhaps based on a declarative option),
# especially since there's no job filtering except based on environments
chmod 600 ${HEPTAPOD_TARBALL_UPLOAD_KEY}
echo "put ${TARBALL_PATH}*" | sftp -b- \
${SSH_FLAGS} \
-i ${HEPTAPOD_TARBALL_UPLOAD_KEY} \
${HEPTAPOD_UPLOAD_SSH_USER}@${HEPTAPOD_DOWNLOAD_SITE}:${HEPTAPOD_UPLOAD_SSH_USER}/${SUBDIR}/src
`dirname $0`/heptapod-sftp-push \
download.heptapod.net \
"$HEPTAPOD_TARBALL_UPLOAD_KEY" \
"$TARBALL_PATH" \
"${SUBDIR}/src"
fi
#!/bin/sh
# Simple script to push any artifact to some Heptapod SFTP server,
# using the heptapod_known_hosts.ssh file
set -eu
SFTP_HOST=$1
# This "key" is just a file name, content is set by file mode of CI variables
HEPTAPOD_UPLOAD_KEY=$2
ARTIFACT=$3
TARGET_DIR=$4
echo "Pushing ${ARTIFACT} to ${SFTP_HOST} via SFTP"
KNOWN_HOSTS=$(realpath $(dirname $0)/heptapod_known_hosts.ssh)
SSH_FLAGS="-o IdentitiesOnly=yes -o UserKnownHostsFile=${KNOWN_HOSTS}"
if [ -n "$HEPTAPOD_UPLOAD_SSH_PORT" ]; then
SSH_FLAGS="$SSH_FLAGS -P $HEPTAPOD_UPLOAD_SSH_PORT"
fi
# TODO it would be nice of the runner to set restrictive permissions
# this right at file creation time (perhaps based on a declarative option),
# especially since there's no job filtering except based on environments
chmod 600 ${HEPTAPOD_UPLOAD_KEY}
# wildcard to include any checksum or signatures
echo "put ${ARTIFACT}*" | sftp -b- \
${SSH_FLAGS} \
-i ${HEPTAPOD_UPLOAD_KEY} \
${HEPTAPOD_UPLOAD_SSH_USER}@${SFTP_HOST}:${HEPTAPOD_UPLOAD_SSH_USER}/${TARGET_DIR}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment