Add new file

This commit is contained in:
Groupr 2025-07-17 01:53:48 +00:00
parent 73f1a2d7a9
commit d96c14cf7f

View file

@ -0,0 +1,72 @@
stages:
- test
- build
- deploy
variables:
DOCKER_IMAGE_NAME: "slop-terminal"
DOCKER_TAG: "$CI_COMMIT_REF_SLUG"
# Test stage
test:
stage: test
image: python:3.9
before_script:
- pip install -r requirements.txt
- pip install pytest pytest-cov
script:
- python -m pytest tests/ --cov=.
coverage: '/TOTAL.+?(\d+\%)$/'
artifacts:
reports:
coverage_report:
coverage_format: cobertura
path: coverage.xml
# Build Docker image
build:
stage: build
image: docker:20.10.16
services:
- docker:20.10.16-dind
before_script:
- docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY
script:
- docker build -t $CI_REGISTRY_IMAGE:$DOCKER_TAG .
- docker push $CI_REGISTRY_IMAGE:$DOCKER_TAG
- docker tag $CI_REGISTRY_IMAGE:$DOCKER_TAG $CI_REGISTRY_IMAGE:latest
- docker push $CI_REGISTRY_IMAGE:latest
only:
- main
- develop
# Deploy to staging
deploy_staging:
stage: deploy
image: alpine:latest
before_script:
- apk add --no-cache curl
script:
- echo "Deploying to staging environment..."
- curl -X POST "$STAGING_WEBHOOK_URL" -H "Content-Type: application/json" -d '{"image":"'$CI_REGISTRY_IMAGE:$DOCKER_TAG'"}'
only:
- develop
environment:
name: staging
url: https://staging.your-domain.com
# Deploy to production
deploy_production:
stage: deploy
image: alpine:latest
before_script:
- apk add --no-cache curl
script:
- echo "Deploying to production environment..."
- curl -X POST "$PRODUCTION_WEBHOOK_URL" -H "Content-Type: application/json" -d '{"image":"'$CI_REGISTRY_IMAGE:$DOCKER_TAG'"}'
only:
- main
environment:
name: production
url: https://your-domain.com
when: manual