From c00916decf5d8d7a80a3cd9076e9873f7774da64 Mon Sep 17 00:00:00 2001 From: Florian Hoss Date: Mon, 30 Sep 2024 22:25:44 +0200 Subject: [PATCH] Update .gitlab-ci.yml --- .gitlab-ci.yml | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 4c6e328..ec6313e 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,11 +1,13 @@ stages: - build + - cleanup + - publish variables: LATEST_IMAGE: '$CI_REGISTRY_IMAGE:latest' PRODUCTION_URL: 'https://home.unjx.de' -image: docker:$V_DOCKER +image: docker:${V_DOCKER}-dind .auth_gitlab: before_script: @@ -40,3 +42,19 @@ build: --push after_script: - !reference [.auth_gitlab, after_script] + +cleanup: + rules: !reference [.rules:deploy, rules] + stage: cleanup + script: + - docker system prune -a -f + - docker volume prune -a -f + +publish: + rules: !reference [.rules:deploy, rules] + stage: publish + script: + - cp "$SSH_PRIVATE_KEY" ~/.ssh/bot + - chmod 600 ~/.ssh/bot + - ssh-keyscan -H ${SERVER} >> ~/.ssh/known_hosts + - ssh -i ~/.ssh/bot flohoss@${SERVER} "cd /opt/docker/home && docker compose pull && docker compose up -d"