Update .gitlab-ci.yml

This commit is contained in:
Florian Hoss 2024-09-30 22:25:44 +02:00
parent 8c5b698acb
commit c00916decf
Signed by: flohoss
GPG key ID: 5BA0B454E498DF62

View file

@ -1,11 +1,13 @@
stages: stages:
- build - build
- cleanup
- publish
variables: variables:
LATEST_IMAGE: '$CI_REGISTRY_IMAGE:latest' LATEST_IMAGE: '$CI_REGISTRY_IMAGE:latest'
PRODUCTION_URL: 'https://home.unjx.de' PRODUCTION_URL: 'https://home.unjx.de'
image: docker:$V_DOCKER image: docker:${V_DOCKER}-dind
.auth_gitlab: .auth_gitlab:
before_script: before_script:
@ -40,3 +42,19 @@ build:
--push --push
after_script: after_script:
- !reference [.auth_gitlab, 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"