diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml new file mode 100644 index 0000000000000000000000000000000000000000..848aa815c9a4cfc59e4274dbe233662431d58600 --- /dev/null +++ b/.gitlab-ci.yml @@ -0,0 +1,34 @@ +stages: + - publish + - deploy + +variables: + REGISTRY: registry.sc07.dev + IMAGE_NAME: $GITLAB_USER_LOGIN/$CI_PROJECT_NAME:edge + +publish: + image: docker + stage: publish + services: + - docker:dind + before_script: + - echo $PAT | docker login $REGISTRY -u $GITLAB_USER_LOGIN --password-stdin + script: + - docker build . --tag $REGISTRY/$IMAGE_NAME + - docker push $REGISTRY/$IMAGE_NAME + +deploy: + image: ubuntu:latest + stage: deploy + only: + - main + before_script: + - apt-get -yq update + - apt-get -yqq install ssh + - install -m 600 -D /dev/null ~/.ssh/id_rsa + - echo "$SSH_PRIVATE_KEY" | base64 -d > ~/.ssh/id_rsa + - ssh-keyscan -H $SSH_HOST > ~/.ssh/known_hosts + script: + - ssh $SSH_USER@$SSH_HOST "cd $WORK_DIR && docker compose pull && docker compose up -d && exit" + after_script: + - rm -rf ~/.ssh