From 02163d1466d5bc62367d6abf514d2e0623cccbb2 Mon Sep 17 00:00:00 2001 From: berkas1 <berka@berkasimon.com> Date: Tue, 21 Sep 2021 09:48:36 +0200 Subject: [PATCH] feat(ci): now deploys to cPanel hosting https://gitlab.ics.muni.cz/cloud/internal-wiki/-/issues/267 https://gitlab.ics.muni.cz/cloud/internal-wiki/-/issues/356 --- .gitlab-ci.yml | 24 +++++++++++++++++++----- config.toml | 2 +- layouts/partials/site-footer.html | 2 +- 3 files changed, 21 insertions(+), 7 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index ed513c2..7daf34c 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -11,16 +11,19 @@ build-test: - apk add python3 - apk add py3-pip - apk add py3-yaml + - apk add openssh-client script: - hugo --config config.toml -D --destination=./public -pages: +deploy_cpanel: before_script: - apk update - apk add git - apk add python3 - apk add py3-pip - apk add py3-yaml + - apk add openssh-client + - apk add curl script: - git clone https://gitlab-ci-token:${CI_JOB_TOKEN}@gitlab.ics.muni.cz/cloud/hiera.git - sed -i '11,$d' content/cloud/flavors/index.md @@ -29,10 +32,21 @@ pages: - cat flavors.csv >> content/cloud/flavors/index.md - echo "{{</csv-table>}}" >> content/cloud/flavors/index.md - cat content/cloud/flavors/index.md + - sed -i -e "s/BUILDIDTAG/$CI_COMMIT_SHORT_SHA/g" ./layouts/partials/site-footer.html - hugo --config config.toml -D --destination=./public - artifacts: - paths: - - public + - eval $(ssh-agent -s) + - echo "$SSH_PRIVATE_KEY_cpanel" | tr -d '\r' | ssh-add - + - mkdir -p ~/.ssh + - chmod 700 ~/.ssh + - echo "$SSH_KNOWN_HOSTS_cpanel" >> ~/.ssh/known_hosts + - chmod 644 ~/.ssh/known_hosts + - ssh docscloudmuni@docs.cloud.muni.cz 'mkdir ~/tmpdeploy' + - scp -r ./public/* docscloudmuni@docs.cloud.muni.cz:~/tmpdeploy + - ssh docscloudmuni@docs.cloud.muni.cz 'mv ~/public_html ~/todelete && mv ~/tmpdeploy ~/public_html && rm -rf ~/todelete' + - sleep 5 + - latest_commit=$(git log -1 --pretty=format:%h ) + - "curl -H 'Cache-Control: no-cache' https://docs.cloud.muni.cz | grep $latest_commit" only: - - master \ No newline at end of file + - master + diff --git a/config.toml b/config.toml index 7d8bb15..a71582b 100644 --- a/config.toml +++ b/config.toml @@ -1,4 +1,4 @@ -baseURL = "https://cloud.gitlab-pages.ics.muni.cz/documentation/" +baseURL = "https://docs.cloud.muni.cz/" languageCode = "en-us" title = "Metacentrum Cloud Documentation" theme = "hugo-geekdoc" diff --git a/layouts/partials/site-footer.html b/layouts/partials/site-footer.html index c56671e..18d1549 100644 --- a/layouts/partials/site-footer.html +++ b/layouts/partials/site-footer.html @@ -1,6 +1,6 @@ <footer class="gdoc-footer"> <div class="container flex flex-wrap"> - + build: BUILDIDTAG {{ with .Site.Params.GeekdocLegalNotice }} <span class="gdoc-footer__item"> <a href="{{ . | relURL }}" class="gdoc-footer__link">Legal Notice</a> -- GitLab