143 lines
3.6 KiB
YAML
143 lines
3.6 KiB
YAML
kind: pipeline
|
|
type: docker
|
|
name: default
|
|
|
|
environment:
|
|
POETRY_VERSION: 1.5.1
|
|
POETRY_VIRTUALENVS_IN_PROJECT: 1
|
|
POETRY_VIRTUALENVS_OPTIONS_ALWAYS_COPY: 1
|
|
PIP_ROOT_USER_ACTION: ignore
|
|
PIP_DISABLE_PIP_VERSION_CHECK: 1
|
|
PIP_NO_CACHE_DIR: 1
|
|
|
|
steps:
|
|
- name: lint
|
|
image: python:3.11-bullseye
|
|
commands:
|
|
- pip install -q "poetry==$POETRY_VERSION"
|
|
- poetry install --with check -n -q
|
|
- poetry self add 'poethepoet[poetry_plugin]' -n -q
|
|
- poetry lint
|
|
when:
|
|
event:
|
|
exclude:
|
|
- tag
|
|
|
|
# not used for now
|
|
# - name: postgres
|
|
# image: postgres
|
|
# environment:
|
|
# POSTGRES_PORT: 5432
|
|
# POSTGRES_USER: galactic
|
|
# POSTGRES_PASSWORD: unicorn
|
|
# POSTGRES_DB: unicorn_post_db
|
|
# detach: true
|
|
# when:
|
|
# event:
|
|
# exclude: tag
|
|
|
|
# not used for now
|
|
# - name: test
|
|
# image: python:3.11-bullseye
|
|
# commands:
|
|
# - pip install -q "poetry==$POETRY_VERSION"
|
|
# - poetry install --with test -n -q
|
|
# - poetry self add 'poethepoet[poetry_plugin]' -n -q
|
|
# - poetry test
|
|
# when:
|
|
# event:
|
|
# exclude: tag
|
|
|
|
- name: versioning
|
|
image: python:3.11-bullseye
|
|
environment:
|
|
SSH_PRIVATE_KEY:
|
|
from_secret: ssh_private_key
|
|
CI_EMAIL: cyberduck@coincoinmail.fr
|
|
CI_USERNAME: drone-ci
|
|
commands:
|
|
- eval `ssh-agent -s`
|
|
- echo "$${SSH_PRIVATE_KEY}" | tr -d '\r' | ssh-add - > /dev/null # add ssh key
|
|
- mkdir -p ~/.ssh
|
|
- chmod 700 ~/.ssh
|
|
- ssh-keyscan -t rsa coincoingit.fr >> ~/.ssh/known_hosts
|
|
- git remote set-url origin $DRONE_GIT_SSH_URL
|
|
- git config --global user.email "${CI_EMAIL}"
|
|
- git config --global user.name "${CI_USERNAME}"
|
|
- git fetch --tags
|
|
- pip install -q "poetry==$POETRY_VERSION"
|
|
- poetry install --only commit -n -q
|
|
- poetry run cz check --message "$${DRONE_COMMIT_MESSAGE}"
|
|
- poetry run cz bump --yes
|
|
- git push origin ${DRONE_BRANCH}
|
|
- git push origin --tags
|
|
when:
|
|
event:
|
|
exclude:
|
|
- tag
|
|
|
|
- name: release
|
|
image: plugins/gitea-release
|
|
settings:
|
|
api_key:
|
|
from_secret: gitea_token
|
|
base_url: https://coincoingit.fr
|
|
files: CHANGELOG.md
|
|
title: ${DRONE_TAG}
|
|
note: CHANGELOG.md
|
|
when:
|
|
event: tag
|
|
|
|
- name: build
|
|
image: docker:dind
|
|
environment:
|
|
REGISTRY_HOST: registry.coincoingit.fr
|
|
IMAGE_NAME: unicorn_post
|
|
DOCKER_USER:
|
|
from_secret: docker_username
|
|
DOCKER_PASSWORD:
|
|
from_secret: docker_password
|
|
commands:
|
|
- echo $DOCKER_PASSWORD | docker login --username $DOCKER_USER --password-stdin $REGISTRY_HOST
|
|
- DOCKER_BUILDKIT=1 docker build -f deployment/Dockerfile -t $REGISTRY_HOST/$IMAGE_NAME:$DRONE_TAG .
|
|
- docker tag $REGISTRY_HOST/$IMAGE_NAME:$DRONE_TAG $REGISTRY_HOST/$IMAGE_NAME:latest
|
|
- docker push $REGISTRY_HOST/$IMAGE_NAME:$DRONE_TAG
|
|
- docker push $REGISTRY_HOST/$IMAGE_NAME:latest
|
|
volumes:
|
|
- name: docker-sock
|
|
path: /var/run/docker.sock
|
|
when:
|
|
event: tag
|
|
|
|
- name: deploy
|
|
image: docker:dind
|
|
environment:
|
|
STACK_NAME: unicorn_post
|
|
POSTGRES_USER:
|
|
from_secret: postgres_user
|
|
POSTGRES_PASSWORD:
|
|
from_secret: postgres_password
|
|
POSTGRES_DB:
|
|
from_secret: postgres_db
|
|
SECRET_KEY:
|
|
from_secret: secret_key
|
|
MQTT_USERNAME:
|
|
from_secret: mqtt_username
|
|
MQTT_PASSWORD:
|
|
from_secret: mqtt_password
|
|
DJANGO_SUPERUSER_USERNAME:
|
|
from_secret: django_superuser_username
|
|
DJANGO_SUPERUSER_PASSWORD:
|
|
from_secret: django_superuser_password
|
|
commands:
|
|
- docker stack deploy -c deployment/stack.yml $STACK_NAME
|
|
volumes:
|
|
- name: docker-sock
|
|
path: /var/run/docker.sock
|
|
when:
|
|
event: tag
|
|
|
|
volumes:
|
|
- name: docker-sock
|
|
host:
|
|
path: /var/run/docker.sock |