diff --git a/ci/gitlab-ci.yml b/ci/gitlab-ci.yml index 648c3d3cad0e5ab765867c51f9d75254705473ac..e34410150770b62d7c8b833a4d47297b4ff7018a 100644 --- a/ci/gitlab-ci.yml +++ b/ci/gitlab-ci.yml @@ -6,9 +6,9 @@ - echo "$UBERSPACE_KNOWN_HOST" >> ~/.ssh/known_hosts include: - - project: 'fit-connect/pipeline' + - project: "fit-connect/pipeline" ref: main - file: 'trivy.gitlab-ci.yml' + file: "trivy.gitlab-ci.yml" cache: paths: @@ -19,6 +19,9 @@ stages: - build - deploy +variables: + DEPLOY_SERVER: fitko@dorado.uberspace.de + trivy-filesystem: extends: .trivy-filesystem variables: @@ -36,10 +39,29 @@ build: - out/ expire_in: 1 hour +deploy:review: + stage: deploy + image: alpine:latest + environment: + name: review/$CI_COMMIT_REF_NAME + on_stop: undeploy:review + auto_stop_in: 1 week + url: https://docs-preview.fitko.dev/review/$CI_COMMIT_REF_SLUG/ + dependencies: + - build + rules: + - if: $CI_COMMIT_BRANCH != $CI_DEFAULT_BRANCH + before_script: + - *pre-deploy-uber-space-setup + script: + - rsync -rLvz --delete --checksum -e "ssh -o CheckHostIP=no" --ipv4 --progress ./out/. $DEPLOY_SERVER:docs-preview.fitko.dev/review/$CI_COMMIT_REF_SLUG/ + deploy: stage: deploy - image: - name: alpine:latest + image: alpine:latest + environment: + name: live + url: https://docs-preview.fitko.dev/ dependencies: - build rules: @@ -47,4 +69,20 @@ deploy: before_script: - *pre-deploy-uber-space-setup script: - - rsync -rLvz --delete --checksum -e "ssh -o CheckHostIP=no" --ipv4 --progress ./out/. fitko@dorado.uberspace.de:docs-preview.fitko.dev + - rsync -rLvz --delete --checksum -e "ssh -o CheckHostIP=no" --ipv4 --progress ./out/. $DEPLOY_SERVER:docs-preview.fitko.dev + +undeploy:review: + stage: .post + image: alpine:latest + environment: + name: review/$CI_COMMIT_REF_NAME + action: stop + needs: + - deploy:review + rules: + - if: $CI_MERGE_REQUEST_ID + when: manual + before_script: + - *pre-deploy-uber-space-setup + script: + - ssh $DEPLOY_SERVER "rm -rf docs-preview.fitko.dev/review/$CI_COMMIT_REF_SLUG/"