54 lines
1.2 KiB
YAML
54 lines
1.2 KiB
YAML
default:
|
|
tags:
|
|
- universal
|
|
|
|
stages:
|
|
- tests
|
|
- build-and-push
|
|
- deploy
|
|
|
|
tests_job1:
|
|
stage: tests
|
|
image: python:3.11-slim
|
|
variables:
|
|
PYTHONPATH: "."
|
|
before_script:
|
|
- pip install --no-cache-dir -r requirements.txt
|
|
- pip install pytest
|
|
script:
|
|
- pytest tests/
|
|
|
|
build_job1:
|
|
image:
|
|
|
|
|
|
push_job:
|
|
stage: build-and-push
|
|
image:
|
|
name: gcr.io/kaniko-project/executor:v1.23.0-debug
|
|
entrypoint: [""]
|
|
before_script:
|
|
- mkdir -p /kaniko/.docker
|
|
- cp "$DOCKER_AUTH_CONFIG" /kaniko/.docker/config.json
|
|
script:
|
|
- >
|
|
/kaniko/executor
|
|
--context "${CI_PROJECT_DIR}"
|
|
--dockerfile "${CI_PROJECT_DIR}/Dockerfile"
|
|
--destination "${DOCKERHUB_USER}/quote-bot:${CI_COMMIT_SHORT_SHA}"
|
|
--destination "${DOCKERHUB_USER}/quote-bot:latest"
|
|
|
|
deploy_to_server:
|
|
stage: deploy
|
|
image: ghcr.io/ansible/creator-ee:v0.22.0
|
|
variables:
|
|
ANSIBLE_HOST_KEY_CHECKING: "False"
|
|
before_script:
|
|
- mkdir -p ~/.ssh
|
|
- chmod 700 ~/.ssh
|
|
- echo "$ANSIBLE_PRIVATE_KEY" > ~/.ssh/id_ed25519
|
|
- chmod 600 ~/.ssh/id_ed25519
|
|
- ansible-galaxy collection install community.docker
|
|
script:
|
|
- cd auto-deployment/
|
|
- ansible-playbook -i inventory.ini A_deploy.yml |