From cedadce30f73da426a10856c20c0a59d3caec991 Mon Sep 17 00:00:00 2001 From: Frank Sauerburger <frank@sauerburger.com> Date: Wed, 27 Mar 2019 10:46:09 +0100 Subject: [PATCH] Add preview badge --- .gitlab-ci.yml | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 9586770..f4eed58 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -16,6 +16,12 @@ stages: - echo "${SFTP_HOSTCERT}" > ~/.ssh/known_hosts - chmod 600 ~/.ssh/* - mv ${LOCAL_DIR} ${REMOTE_DIR} + - > + if [ ! -z "${PREVIEW}" ]; then + find ${REMOTE_DIR} -type f -print0 | xargs -0 sed -i 's;</body>;<script src="/.version.js"></script></body>;g'; + echo "document.body.innerHTML += '<div style=\"position:fixed; bottom:60px; right:-60px; background-color:#d34; padding: 6px 100px; transform: rotate(-45deg); border-top: 1px solid #400; border-bottom: 1px solid #400;\"><a href=\"${CI_PROJECT_URL}/commit/${CI_COMMIT_SHA}\" style=\"color:#fff;\">Preview: ${CI_COMMIT_SHA:0:8}</a></div>';" > ${REMOTE_DIR}/.version.js; + fi; + - sftp ${SFTP_USERNAME}@${SFTP_HOST} <<< "put -r ${REMOTE_DIR}" @@ -43,6 +49,7 @@ test_deploy: SFTP_HOSTCERT: ${TEST_HOSTCERT} REMOTE_DIR: ${TEST_DIR} GIT_STRATEGY: none + PREVIEW: "true" environment: name: Preview -- GitLab