1
0
mirror of https://gitlab.com/MoonTestUse1/AdministrationItDepartmens.git synced 2025-08-14 00:25:46 +02:00

Edit .gitlab-ci.yml

This commit is contained in:
Александр Лесников
2025-01-06 02:54:12 +00:00
parent 4d5b18c590
commit d700ad7f4a

View File

@@ -1,32 +1,42 @@
image: python:3.11
stages: # List of stages for jobs, and their order of execution
- build
stages:
- test
- deploy
build-job: # This job runs in the build stage, which runs first.
stage: build
script:
- echo "Compiling the code..."
- echo "Compile complete."
variables:
DOCKER_HOST: tcp://docker:2375
SSH_PRIVATE_KEY: "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAACAQDI1N1+AZhGX1QHu6x5vzH3kLiWnddDkKd4gkok+9Vu2dhREiQ/uIVJA1KZgqUZ0vdaD1GTJmtDN6qvn0ef7GIvKE9QuGki/JimFmrZJx75jfsXt2Un7/lTX1Zfa1O9n2fGPFuULGEj7A4eeIxe9RVjbbYRyJR30j2oJ9wr0wC7IP6pnjDZELoJYLEm9x1UfwQeQp6f"
unit-test-job: # This job runs in the test stage.
stage: test # It only starts when the job in the build stage completes successfully.
script:
- echo "Running unit tests... This will take about 60 seconds."
- sleep 60
- echo "Code coverage is 90%"
services:
- docker:dind
lint-test-job: # This job also runs in the test stage.
stage: test # It can run at the same time as unit-test-job (in parallel).
script:
- echo "Linting code... This will take about 10 seconds."
- sleep 10
- echo "No lint issues found."
before_script:
- python -V
- pip install -r backend/requirements.txt
deploy-job: # This job runs in the deploy stage.
stage: deploy # It only runs when *both* jobs in the test stage complete successfully.
environment: production
test:
stage: test
script:
- echo "Deploying application..."
- echo "Application successfully deployed."
- cd backend
- pytest -v
only:
- main
- Testing
deploy:
stage: deploy
script:
- apt-get update -qy
- apt-get install -y openssh-client
- mkdir -p ~/.ssh
- chmod 700 ~/.ssh
- echo "$SSH_PRIVATE_KEY" | tr -d '\r' > ~/.ssh/id_rsa
- chmod 600 ~/.ssh/id_rsa
- echo -e "Host *\n\tStrictHostKeyChecking no\n\n" > ~/.ssh/config
- scp -r * root@185.139.70.62:/root/app/
- ssh root@185.139.70.62 "cd /root/app && docker-compose down && docker-compose up -d"
only:
- main
environment:
name: production