diff --git a/.ci/build_indices.sh b/.ci/build_indices.sh index ea563f40feb28c4e551695e2621ae4a39aea9017..0c2d4067ee29969871390250be3038ad39c7d5a8 100644 --- a/.ci/build_indices.sh +++ b/.ci/build_indices.sh @@ -1,31 +1,19 @@ #!/bin/bash -DIRECTORY=build - # Install lunr to build the index -npm install lunr@2.3.8 +npm install lunr@$LUNR_VERSION -# Go to the directory... +# Go to the directory containing the built website... cd $DIRECTORY -printf "Found the following build targets inside: \n$(ls -d */)\n\n" - -# ...and loop through all the build targets -for branch in $(ls -d */); do - echo "Entering: $branch"; - - cd "$branch"; - - echo "Generating the index..." - cat documents.js | node $CI_PROJECT_DIR/build_index.js > index.js - rm documents.js build_index.js +echo "Generating the index..." - echo "...should be completed. First 50 characters of the index: " - cat index.js | head -c50 - echo "" +# Pipe documents.js file (which should be generated by Jekyll after building the website) through build script +cat documents.js | node build_index.js > index.js - cd .. - -done +# Show the results (should not be empty) +echo "...should be completed. First 50 characters of the index: " +cat index.js | head -c50 +echo "" -rm $CI_PROJECT_DIR/build_index.js +rm documents.js build_index.js diff --git a/.ci/deploy.sh b/.ci/deploy.sh deleted file mode 100644 index d6f5cceb7ad6b0dc94884c6f71ceda2aeff5dc9e..0000000000000000000000000000000000000000 --- a/.ci/deploy.sh +++ /dev/null @@ -1,35 +0,0 @@ -mkdir -p build -artefact="latest" - -# loop through all the branches -for branch in $(git for-each-ref --format='%(refname:strip=3)' refs/remotes); do - echo $branch; - if [[ $branch == "master" ]]; then - artefact="stable"; - elif [[ $branch == "develop" ]]; then - artefact="latest"; - else - artefact="unstable"; - fi - echo $artefact; - git checkout -f $branch - git reset --hard $branch - git pull - - # build the website - bundle install - bundle exec jekyll build --baseurl="howto-cards/$artefact" -d "build/$artefact" - - if [[ $branch == "master" ]]; then - # set the 404 - cp howto-cards/$artefact/404.html build/404.html - fi -done - -# checkout the current branch -echo $CI_COMMIT_REF_NAME -git checkout -f $CI_COMMIT_REF_NAME -git reset --hard origin/$CI_COMMIT_REF_NAME - -# set the auto redirection -cp .ci/.autoRedirect build/index.html diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index b6ccc3f31fc7d1a147c8a9ea2a709fe409d1101e..134ec634a0e72f564fc9ff5d748fb9f450852e4f 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -8,27 +8,35 @@ stages: build_pages: stage: build - before_script: - - apt-get -qq update - - apt-get install -y -qq git-lfs - - gem install bundler:2.0.2 && bundle install - script: - - bash .ci/deploy.sh variables: JEKYLL_ENV: production + BUNDLER_VERSION: 2.0.2 artifacts: expire_in: 1 day paths: - build + before_script: + - gem install bundler:$BUNDLER_VERSION && bundle install + script: + # Generate the configuration for forks (will use Gitlab Pages on personal namespaces) + - 'echo "url: https://$CI_PROJECT_NAMESPACE.$CI_PAGES_DOMAIN\nbaseurl: /$CI_PROJECT_NAME" >> _config_gitlab_pages.yml' + + # If there is no config for the current branch, use the one for Gitlab Pages + - 'if [ ! -f "_config_$CI_COMMIT_REF_NAME.yml" ]; then mv _config_gitlab_pages.yml _config_$CI_COMMIT_REF_NAME.yml; fi' + + # Display, which configuration is used + - 'echo "Configuration: " && cat "_config_$CI_COMMIT_REF_NAME.yml"' + + # Run Jekyll with custom configuration + - bundle exec jekyll build -d build --config "_config.yml,_config_$CI_COMMIT_REF_NAME.yml" generate the search index: stage: generate_index image: node:13.8.0-slim - rules: - - if: $CI_COMMIT_BRANCH == "master" - - if: $CI_COMMIT_BRANCH == "develop" - - if: $CI_COMMIT_BRANCH == "16-deploy-to-staticpages-vm" + variables: + LUNR_VERSION: 2.3.8 + DIRECTORY: build script: - bash .ci/build_indices.sh - mv build processed_build @@ -37,14 +45,16 @@ generate the search index: paths: - processed_build +# Deploy to Gitlab Pages - to be run only by forks pages: image: alpine:3.11.3 stage: deploy rules: - - if: $CI_COMMIT_BRANCH == "master" - - if: $CI_COMMIT_BRANCH == "develop" + - if: '$CI_PROJECT_NAMESPACE != "R3" && $CI_PROJECT_NAMESPACE != "R3-core"' script: - - mv processed_build public + # For safety reasons: + - sleep 3600 && exit -1 + - mv processed_buildXXXXX publicXXXX artifacts: expire_in: 1 week paths: @@ -67,7 +77,9 @@ Deploy to production: - if: '$CI_COMMIT_BRANCH == "master" && $CI_PROJECT_PATH == "R3/howto-cards"' - if: '$CI_COMMIT_BRANCH == "16-deploy-to-staticpages-vm"' script: - - ssh -p $SSHPORT $SSHCONNECT "mkdir -p ~/sources/public/web_$CI_JOB_ID ~/master" + # Disable that for now + - sleep 3600 && exit -1 + - ssh -p $SSHPORT $SSHCONNECT "mkdir -p ~/sources/$CI_COMMIT_BRANCH/$CI_JOB_ID ~/master ~/develop" - scp -P $SSHPORT -r processed_build/* $SSHCONNECT:~/sources/public/web_$CI_JOB_ID - ssh -p $SSHPORT $SSHCONNECT "cd ~/master && ln -fs ~/sources/public/web_$CI_JOB_ID/* . && cd ~/sources/public/ && find . -type d -not -newermt '-1 minutes' -exec rm -rf {} +;" diff --git a/_config.yml b/_config.yml index e30c3e4981738efa1b0600d17e5e2572c739091d..b46d209e21ed72dd2d851e6015b2fdb854d234c8 100644 --- a/_config.yml +++ b/_config.yml @@ -19,8 +19,8 @@ description: >- # this means to ignore newlines until "baseurl:" This page is an index for lab cards that are intended to provide practical guidance in implementing Data Management, Data Protection and IT setup. # URL settings (the most difficult part, please refer to the guide) -baseurl: "/howto-cards" # the subpath of your site, e.g. /gitlab-repository-name -url: "https://r3.pages.uni.lu" # the base hostname & protocol for your site, e.g. http://gitlab-namespace-name.pages.uni.lu/ +baseurl: "/" # the subpath of your site, e.g. /gitlab-repository-name +url: "https://localhost" # the base hostname & protocol for your site, e.g. http://gitlab-namespace-name.pages.uni.lu/ # Banner settings banner: howto-card # When you have custom images, change this setting's value to the name of the folder containing them @@ -62,6 +62,8 @@ plugins: # The display logic itself is in the template share_url: https://howto.lcsb.uni.lu/? include_link_index: 4 + +# These values are injected into cards defaults: - scope: diff --git a/_config_devel.yml b/_config_devel.yml new file mode 100644 index 0000000000000000000000000000000000000000..2209ccb97ea25544c0bf5861d4575952a68dcdd3 --- /dev/null +++ b/_config_devel.yml @@ -0,0 +1,2 @@ +url: "https://howto-latest.lcsb.uni.lu" +baseurl: "/" diff --git a/_config_master.yml b/_config_master.yml new file mode 100644 index 0000000000000000000000000000000000000000..5366871f6f2740337e2089472682b3c3fe20ebd0 --- /dev/null +++ b/_config_master.yml @@ -0,0 +1,2 @@ +url: "https://howto.lcsb.uni.lu" +baseurl: "/"