From e751e8175f4650a89b0b3aba06a7b99aac3346fa Mon Sep 17 00:00:00 2001 From: Dimitrios Giannopoulos Date: Tue, 23 Jan 2024 10:04:57 +0000 Subject: [PATCH 1/7] added job to create multi version docs --- .gitlab-ci.yml | 28 ++++++++++++++++++++++++---- 1 file changed, 24 insertions(+), 4 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index fedf490d..76c5858d 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,11 +1,31 @@ pages: stage: deploy image: python:3.9.18-slim-bullseye + variables: + PIP_CACHE_DIR: "$CI_PROJECT_DIR/.cache/pip" + PAGES_BRANCH: gitlab-pages + HTTPS_REMOTE: https://gitlab-ci-token:${ACCESS_TOKEN}@${CI_SERVER_HOST}/rep/${CI_PROJECT_PATH}.git + before_script: + - pip install -q mkdocs-material mike + - apt-get update -qq && apt-get -qq install -y git > /dev/null + - git config user.name $GITLAB_USER_NAME + - git config user.email $GITLAB_USER_EMAIL + - git fetch origin $PAGES_BRANCH && git checkout $PAGES_BRANCH || git checkout -b $PAGES_BRANCH origin/$PAGES_BRANCH || echo "Pages branch not deployed yet." + - git checkout $CI_COMMIT_SHA script: - - pip install mkdocs-material - - mkdocs build --site-dir public + - | + if [ -n "$CI_COMMIT_TAG" ]; then + mike deploy --deploy-prefix public -r $HTTPS_REMOTE -p -b $PAGES_BRANCH -u $CI_COMMIT_TAG latest + mike set-default --deploy-prefix public -r $HTTPS_REMOTE -p -b $PAGES_BRANCH latest + elif [ "$CI_COMMIT_REF_PROTECTED" == "true" ]; then + mike deploy --deploy-prefix public -r $HTTPS_REMOTE -p -b $PAGES_BRANCH -u $CI_COMMIT_BRANCH $CI_COMMIT_BRANCH + fi + git checkout $PAGES_BRANCH -- public/ artifacts: paths: - - public + - public/ rules: - - if: '$CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH' + - if: '$CI_COMMIT_TAG' + - if: '$CI_COMMIT_REF_PROTECTED == "true"' + when: always + - when: never \ No newline at end of file -- GitLab From e6b3efe3d9f157febed580575bc78e1da7237f2a Mon Sep 17 00:00:00 2001 From: Dimitrios Giannopoulos Date: Tue, 23 Jan 2024 10:40:21 +0000 Subject: [PATCH 2/7] fixes for git and mike --- .gitlab-ci.yml | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 76c5858d..f5962945 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -8,19 +8,20 @@ pages: before_script: - pip install -q mkdocs-material mike - apt-get update -qq && apt-get -qq install -y git > /dev/null - - git config user.name $GITLAB_USER_NAME - - git config user.email $GITLAB_USER_EMAIL + - git config --global --replace-all user.name $GITLAB_USER_NAME + - git config --global --replace-all user.email $GITLAB_USER_EMAIL - git fetch origin $PAGES_BRANCH && git checkout $PAGES_BRANCH || git checkout -b $PAGES_BRANCH origin/$PAGES_BRANCH || echo "Pages branch not deployed yet." - git checkout $CI_COMMIT_SHA script: + - git pull --rebase origin $PAGES_BRANCH - | if [ -n "$CI_COMMIT_TAG" ]; then mike deploy --deploy-prefix public -r $HTTPS_REMOTE -p -b $PAGES_BRANCH -u $CI_COMMIT_TAG latest mike set-default --deploy-prefix public -r $HTTPS_REMOTE -p -b $PAGES_BRANCH latest elif [ "$CI_COMMIT_REF_PROTECTED" == "true" ]; then - mike deploy --deploy-prefix public -r $HTTPS_REMOTE -p -b $PAGES_BRANCH -u $CI_COMMIT_BRANCH $CI_COMMIT_BRANCH + mike deploy --deploy-prefix public -r $HTTPS_REMOTE -p -b $PAGES_BRANCH -u $CI_COMMIT_BRANCH fi - git checkout $PAGES_BRANCH -- public/ + - git checkout $PAGES_BRANCH -- public/ artifacts: paths: - public/ -- GitLab From 7f3339925c2aee2f37be7d0730c347a665c7365f Mon Sep 17 00:00:00 2001 From: Dimitrios Giannopoulos Date: Tue, 23 Jan 2024 10:41:42 +0000 Subject: [PATCH 3/7] testing with new branch --- .gitlab-ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index f5962945..d3ed7cc0 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -3,7 +3,7 @@ pages: image: python:3.9.18-slim-bullseye variables: PIP_CACHE_DIR: "$CI_PROJECT_DIR/.cache/pip" - PAGES_BRANCH: gitlab-pages + PAGES_BRANCH: gitlab-pages2 HTTPS_REMOTE: https://gitlab-ci-token:${ACCESS_TOKEN}@${CI_SERVER_HOST}/rep/${CI_PROJECT_PATH}.git before_script: - pip install -q mkdocs-material mike -- GitLab From c2afc2a3f003b948856119f9a957d700cd390884 Mon Sep 17 00:00:00 2001 From: Dimitrios Giannopoulos Date: Tue, 23 Jan 2024 10:42:54 +0000 Subject: [PATCH 4/7] removed git pull rebase from flow --- .gitlab-ci.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index d3ed7cc0..fc2f9688 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -13,7 +13,6 @@ pages: - git fetch origin $PAGES_BRANCH && git checkout $PAGES_BRANCH || git checkout -b $PAGES_BRANCH origin/$PAGES_BRANCH || echo "Pages branch not deployed yet." - git checkout $CI_COMMIT_SHA script: - - git pull --rebase origin $PAGES_BRANCH - | if [ -n "$CI_COMMIT_TAG" ]; then mike deploy --deploy-prefix public -r $HTTPS_REMOTE -p -b $PAGES_BRANCH -u $CI_COMMIT_TAG latest -- GitLab From 1c3342babaccec6b684009010000f65283622e2a Mon Sep 17 00:00:00 2001 From: Dimitrios Giannopoulos Date: Tue, 23 Jan 2024 10:44:55 +0000 Subject: [PATCH 5/7] using correct publish branch --- .gitlab-ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index fc2f9688..5c02018e 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -3,7 +3,7 @@ pages: image: python:3.9.18-slim-bullseye variables: PIP_CACHE_DIR: "$CI_PROJECT_DIR/.cache/pip" - PAGES_BRANCH: gitlab-pages2 + PAGES_BRANCH: gitlab-pages HTTPS_REMOTE: https://gitlab-ci-token:${ACCESS_TOKEN}@${CI_SERVER_HOST}/rep/${CI_PROJECT_PATH}.git before_script: - pip install -q mkdocs-material mike -- GitLab From d1aaadb2eb5eb7b2d40695619f89a6d97a742346 Mon Sep 17 00:00:00 2001 From: Dimitrios Giannopoulos Date: Tue, 23 Jan 2024 10:53:22 +0000 Subject: [PATCH 6/7] changed publish branch --- .gitlab-ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 5c02018e..48220cc6 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -3,7 +3,7 @@ pages: image: python:3.9.18-slim-bullseye variables: PIP_CACHE_DIR: "$CI_PROJECT_DIR/.cache/pip" - PAGES_BRANCH: gitlab-pages + PAGES_BRANCH: gl-pages HTTPS_REMOTE: https://gitlab-ci-token:${ACCESS_TOKEN}@${CI_SERVER_HOST}/rep/${CI_PROJECT_PATH}.git before_script: - pip install -q mkdocs-material mike -- GitLab From 532b80578d817f5d873f2884737826579a4bd0de Mon Sep 17 00:00:00 2001 From: Dimitrios Giannopoulos Date: Tue, 23 Jan 2024 14:50:16 +0000 Subject: [PATCH 7/7] trigger if branch is develop --- .gitlab-ci.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 48220cc6..20f28f1d 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -17,7 +17,7 @@ pages: if [ -n "$CI_COMMIT_TAG" ]; then mike deploy --deploy-prefix public -r $HTTPS_REMOTE -p -b $PAGES_BRANCH -u $CI_COMMIT_TAG latest mike set-default --deploy-prefix public -r $HTTPS_REMOTE -p -b $PAGES_BRANCH latest - elif [ "$CI_COMMIT_REF_PROTECTED" == "true" ]; then + elif [ "$CI_COMMIT_REF_NAME" == "develop" ]; then mike deploy --deploy-prefix public -r $HTTPS_REMOTE -p -b $PAGES_BRANCH -u $CI_COMMIT_BRANCH fi - git checkout $PAGES_BRANCH -- public/ @@ -26,6 +26,6 @@ pages: - public/ rules: - if: '$CI_COMMIT_TAG' - - if: '$CI_COMMIT_REF_PROTECTED == "true"' + - if: '$CI_COMMIT_REF_NAME == "develop"' when: always - when: never \ No newline at end of file -- GitLab