diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml new file mode 100644 index 0000000000000000000000000000000000000000..1c5144f965648549402758dd1c0f152533af80e9 --- /dev/null +++ b/.gitlab-ci.yml @@ -0,0 +1,102 @@ +variables: + GIT_SUBMODULE_STRATEGY: recursive + GIT_SUBMODULE_FORCE_HTTPS: "true" + SECURE_FILES_DOWNLOAD_PATH: './' + +stages: + - build + - deploy + - post_deploy + +build:zola: + stage: build + image: rust:slim-bookworm + script: + ## + ## Install dependencies + ## + - apt update + - apt upgrade -y + - apt install wget nodejs npm -y + - wget https://github.com/getzola/zola/releases/download/v0.18.0/zola-v0.18.0-x86_64-unknown-linux-gnu.tar.gz + - tar xzvf zola-v0.18.0-x86_64-unknown-linux-gnu.tar.gz + - mv zola /usr/local/bin + - chmod +x /usr/local/bin/zola + - git submodule update --remote + + - cd lattice-boltzmann.com + - zola build + + - mkdir -p $ARTIFACTS_FOLDER + - mv public/* $ARTIFACTS_FOLDER/ + artifacts: + untracked: true + paths: + - $ARTIFACTS_FOLDER/* + expire_in: 1 day + rules: + - if: '$CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH' + +deploy:ftp: + stage: deploy + image: rust:slim-bookworm + script: + ## + ## Install dependencies + ## + - apt update + - apt upgrade -y + - apt install rsync wget openssh-client -y + - wget https://github.com/getzola/zola/releases/download/v0.18.0/zola-v0.18.0-x86_64-unknown-linux-gnu.tar.gz + - tar xzvf zola-v0.18.0-x86_64-unknown-linux-gnu.tar.gz + - mv zola /usr/local/bin + - chmod +x /usr/local/bin/zola + + ## + ## Run ssh-agent (inside the build environment) + ## + - eval $(ssh-agent -s) + + ## + ## Add the SSH key stored in SSH_PRIVATE_KEY variable to the agent store + ## We're using tr to fix line endings which makes ed25519 keys work + ## without extra base64 encoding. + ## https://gitlab.com/gitlab-examples/ssh-private-key/issues/1#note_48526556 + ## + - echo "$SSH_PRIVATE_KEY" | tr -d '\r' | ssh-add - > /dev/null + + ## + ## Create the SSH directory and give it the right permissions + ## + - mkdir -p ~/.ssh + - chmod 700 ~/.ssh + + ## + ## Add host id to known_hosts + ## + - echo "$SSH_KNOWN_HOSTS" > ~/.ssh/known_hosts + - chmod 644 ~/.ssh/known_hosts + + ## + ## Upload the public folder to the server + ## + - rsync -avz $ARTIFACTS_FOLDER/* qw1m6e_malas@qw1m6e.ftp.infomaniak.com:sites/lattice-boltzmann --delete + rules: + - if: '$CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH' + +post_deploy:check_links: + stage: post_deploy + image: rust:slim-bookworm + script: + ## + ## Install dependencies + ## + - apt update + - apt upgrade -y + - apt install nodejs npm -y + - npm install broken-link-checker -g + + - blc https://www.lattice-boltzmann.com/ -ro + allow_failure: false + rules: + - if: '$CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH'