emulator-smev.service/.drone.yml

205 lines
5.7 KiB
YAML
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

kind: pipeline
name: default
type: docker
steps:
- name: restore-cache
image: drillster/drone-volume-cache
volumes:
- name: cache
path: /cache
settings:
restore: true
mount:
- /cache
- name: build
image: plugins/docker
environment:
DOCKER_BUILDKIT: 1
settings:
registry: nexus.essocode.ru:5001
repo: nexus.essocode.ru:5001/ess/emulator-smev
insecure: true
cache: true
tags:
- latest
- ${DRONE_SOURCE_BRANCH/\//-}
- ${DRONE_SOURCE_BRANCH/\//-}-${DRONE_COMMIT}
cache_from:
- nexus.essocode.ru:5001/ess/emulator-smev:master
- nexus.essocode.ru:5001/ess/emulator-smev:${DRONE_SOURCE_BRANCH/\//-}
dockerfile: ./build/Dockerfile
username:
from_secret: docker_login
password:
from_secret: docker_pass
config:
from_secret: dockerconfig
build_args:
from_secret: build_args_nexus
volumes:
- name: dockersock
path: /var/run/docker.sock
- name: cache
path: /cache
depends_on:
- restore-cache
- name: rebuild-cache
image: drillster/drone-volume-cache
volumes:
- name: cache
path: /cache
settings:
rebuild: true
mount:
- /cache
depends_on:
- build
- name: create-dev-config
image: alpine/helm:3.12.3
commands:
- helm template emulator-smev ./deploy/helm --namespace dev --values ./deploy/helm/ocode-dev-values.yaml --set image.tag=${DRONE_SOURCE_BRANCH/\//-}-${DRONE_COMMIT} > ./deploy/helm/k8s-emulator-smev.yaml
depends_on:
- rebuild-cache
when:
branch:
- develop
- name: deploy-dev
image: alpine/k8s:1.32.2
environment:
KUBECONFIG_CONTENT:
from_secret: kubeconfig
commands:
- export KUBE_TMP_DIR=$(mktemp -d)
- echo "$KUBECONFIG_CONTENT" > $KUBE_TMP_DIR/config
- chmod 600 $KUBE_TMP_DIR/config
- echo "File permissions:"
- ls -la $KUBE_TMP_DIR/
- echo "Kubectl version:"
- kubectl version --client
- cat ./deploy/helm/k8s-emulator-smev.yaml
- kubectl --kubeconfig=$KUBE_TMP_DIR/config apply -f ./deploy/helm/k8s-emulator-smev.yaml
depends_on:
- create-dev-config
when:
branch:
- develop
- name: create-rel-config
image: alpine/helm:3.12.3
commands:
- helm template emulator-smev ./deploy/helm --namespace dev --values ./deploy/helm/ocode-rel-ok-values.yaml --set image.tag=${DRONE_SOURCE_BRANCH/\//-}-${DRONE_COMMIT} > ./deploy/helm/k8s-emulator-smev.yaml
depends_on:
- rebuild-cache
when:
branch:
- rel
- name: deploy-rel
image: alpine/k8s:1.32.2
environment:
KUBECONFIG_CONTENT:
from_secret: kubeconfig
commands:
- export KUBE_TMP_DIR=$(mktemp -d)
- echo "$KUBECONFIG_CONTENT" > $KUBE_TMP_DIR/config
- chmod 600 $KUBE_TMP_DIR/config
- echo "File permissions:"
- ls -la $KUBE_TMP_DIR/
- echo "Kubectl version:"
- kubectl version --client
- cat ./deploy/helm/k8s-emulator-smev.yaml
- kubectl --kubeconfig=$KUBE_TMP_DIR/config apply -f ./deploy/helm/k8s-emulator-smev.yaml
depends_on:
- create-rel-config
when:
branch:
- rel
- name: notify-deploy-success
image: appleboy/drone-telegram
settings:
token:
from_secret: telegram_bot_token
to:
from_secret: telegram_chat_id
message: |
🚀 Деплой успешно отправлен!
Сборка #{{build.number}}
Репозиторий: {{repo.name}}
Ветка: {{commit.branch}}
Подробнее: [Ссылка на сборку]({{build.link}})
when:
status: [ success ]
depends_on:
- deploy-dev
- deploy-rel
- name: notify-deploy-failure
image: appleboy/drone-telegram
settings:
token:
from_secret: telegram_bot_token
to:
from_secret: telegram_chat_id
message: |
❌ Деплой не отправлен!
Сборка #{{build.number}}
Репозиторий: {{repo.name}}
Ветка: {{commit.branch}}
Подробнее: [Ссылка на сборку]({{build.link}})
when:
status: [ failure ]
depends_on:
- deploy-dev
- deploy-rel
- name: notify-build-status
image: appleboy/drone-telegram
settings:
token:
from_secret: telegram_bot_token
to:
from_secret: telegram_chat_id
message: |
{{#eq build.status "success"}}📣 Сборка #{{build.number}} завершилась со статусом: {{build.status}}!{{/eq}}
{{#eq build.status "failure"}}🧱 Сборка #{{build.number}} завершилась со статусом: {{build.status}}!{{/eq}}
Репозиторий: {{repo.name}}
Ветка: {{commit.branch}}
Автор: {{commit.author}}
Сообщение: {{commit.message}}
Подробнее: [Ссылка на сборку]({{build.link}})
when:
status: [ success, failure ]
depends_on:
- notify-deploy-success
- notify-deploy-failure
image_pull_secrets:
- dockerconfig
node:
node: 149.154.64.5
trigger:
event:
include:
- push
- tag
- pull_request
- rollback
volumes:
- name: out
temp: {}
- name: dockersock
host:
path: /var/run/docker.sock
- name: cache
host:
path: /tmp/.buildx-cache