Files
fox/ci/deploy/deploy-template.inc.yml
T

46 lines
1.7 KiB
YAML
Raw Normal View History

2025-06-24 10:41:09 +03:00
.deploy-template:
image: harbor.vimpelcom.ru/dockerhub/library/alpine
before_script:
- |
sed -i s%https://dl-cdn.alpinelinux.org/%http://rhrepo.vimpelcom.ru/ext/ya/mirrors/% /etc/apk/repositories && \
apk --no-cache add tzdata ca-certificates curl openssh-client yq jq && \
rm -rf /var/cache/apk/*
- which ssh-agent || (apt-get update -y && apt-get install openssh-client -y)
- eval $(ssh-agent -s)
- mkdir -p ~/.ssh
- echo -n "$TECH_SSH_KEY" | tr -d '\r' > ~/.ssh/id_rsa
- chmod 700 ~/.ssh
- chmod 600 ~/.ssh/id_rsa
2025-06-24 11:45:29 +03:00
- cat ~/.ssh/id_rsa
2025-06-24 10:41:09 +03:00
# https://mikefarah.gitbook.io/yq/operators/traverse-read#nested-special-characters
- STANDS=$(echo "$STANDS" | yq '."'"${CI_COMMIT_REF_NAME}"'".[]')
- RED=$'\033[0;31m'
- RESET=$'\033[0m'
- >
if [[ -z "$STANDS" ]]; then
echo -e "${RED}STANDS for ${CI_COMMIT_REF_NAME:=CI_COMMIT_REF_NAME} is null${RESET}"
exit 1
fi
- >
for stand in $STANDS; do
echo "stand: ${stand}"
ssh-keyscan "${stand}" >> ~/.ssh/known_hosts
done
- chmod 644 ~/.ssh/known_hosts
script:
- >
for stand in $STANDS; do
echo -e "Connect to ${stand}..." &&
2025-06-24 10:45:56 +03:00
scp -o StrictHostKeyChecking=no ci/deploy/deploy.sh "dorootless@${stand}:~/deploy.sh" &&
2025-06-24 10:41:09 +03:00
ssh "dorootless@${stand}" "export CONTAINER_REGISTRY=$CONTAINER_REGISTRY &&
export PRODUCT=$PRODUCT &&
export PRODUCT_VERSION=$PRODUCT_VERSION &&
export IMAGE_NAME=$IMAGE_NAME &&
chmod 700 ~/deploy.sh &&
~/deploy.sh ${IMAGE_NAME} &&
rm -f ~/deploy.sh"
done
needs:
- job: build-image-npm
optional: true