Files
links/.drone.simple.yml
Andrey K. Choi 01532e860a
Some checks failed
continuous-integration/drone/push Build is failing
CI/CD build notifications
2025-11-02 06:33:45 +09:00

175 lines
4.5 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
type: docker
name: catlink-ci
# Trigger настройки
trigger:
branch:
- master
- main
- develop
event:
- push
- pull_request
# Глобальные переменные
environment:
DOCKER_BUILDKIT: 1
COMPOSE_DOCKER_CLI_BUILD: 1
# Этапы пайплайна
steps:
# 1. Установка зависимостей и подготовка
- name: prepare
image: docker:20.10-dind
volumes:
- name: docker
path: /var/run/docker.sock
commands:
- apk add --no-cache make curl git bash
- docker --version
- echo "Repository:$${DRONE_REPO}"
- echo "Branch:$${DRONE_BRANCH}"
- echo "Commit:$${DRONE_COMMIT_SHA:0:8}"
# 2. Линтинг и проверка кода
- name: lint
image: docker:20.10-dind
volumes:
- name: docker
path: /var/run/docker.sock
commands:
- echo "🔍 Running code quality checks..."
- chmod +x ./scripts/ci/lint.sh
- ./scripts/ci/lint.sh
depends_on:
- prepare
# 3. Сборка приложения
- name: build
image: docker:20.10-dind
volumes:
- name: docker
path: /var/run/docker.sock
commands:
- echo "🏗️ Building application..."
- chmod +x ./scripts/ci/build.sh
- ./scripts/ci/build.sh
depends_on:
- lint
# 4. Тестирование
- name: test
image: docker:20.10-dind
volumes:
- name: docker
path: /var/run/docker.sock
environment:
DATABASE_URL: postgres://catlink:catlink@postgres:5432/catlink_test
commands:
- echo "🧪 Running tests..."
- chmod +x ./scripts/ci/test.sh
- ./scripts/ci/test.sh
depends_on:
- build
# 5. Анализ безопасности
- name: security-scan
image: docker:20.10-dind
volumes:
- name: docker
path: /var/run/docker.sock
commands:
- echo "🔒 Running security scans..."
- chmod +x ./scripts/ci/security-scan.sh
- ./scripts/ci/security-scan.sh
depends_on:
- test
failure: ignore # Не останавливаем пайплайн при проблемах безопасности
# 6. Простые уведомления через echo
- name: notify-success
image: alpine:latest
commands:
- echo "✅ BUILD SUCCESS!"
- echo "📁 Repository: $${DRONE_REPO}"
- echo "🌿 Branch: $${DRONE_BRANCH}"
- echo "👤 Author: $${DRONE_COMMIT_AUTHOR}"
- echo "📝 Commit: $${DRONE_COMMIT_SHA:0:8}"
- echo "🔗 Build: $${DRONE_BUILD_LINK}"
depends_on:
- security-scan
when:
status:
- success
- name: notify-failure
image: alpine:latest
commands:
- echo "❌ BUILD FAILED!"
- echo "📁 Repository: $${DRONE_REPO}"
- echo "🌿 Branch: $${DRONE_BRANCH}"
- echo "👤 Author: $${DRONE_COMMIT_AUTHOR}"
- echo "📝 Commit: $${DRONE_COMMIT_SHA:0:8}"
- echo "🔗 Build: $${DRONE_BUILD_LINK}"
depends_on:
- security-scan
when:
status:
- failure
# 7. Уведомления в Telegram
- name: telegram-notify
steps:
- name: telegram
image: appleboy/drone-telegram
settings:
token:
from_secret: 8579410984:AAHQAgz3Lw5r7W_Q352tVY6eFxfussOzREY
to:
from_secret: 556399210
format: markdown
message: |
{{#success build.status}}
✅ *Build Success*
{{else}}
❌ *Build Failed*
{{/success}}
📁 *Repository:* {{repo.name}}
🌿 *Branch:* {{build.branch}}
👤 *Author:* {{build.author}}
📝 *Commit:* `{{truncate build.commit 8}}`
⏱️ *Duration:* {{since build.started}}
🔗 [View Build]({{build.link}})
trigger:
status:
- success
- failure
depends_on:
- catlink-ci
# Сервисы для тестирования
services:
# PostgreSQL для тестов
- name: postgres
image: postgres:14-alpine
environment:
POSTGRES_DB: catlink_test
POSTGRES_USER: catlink
POSTGRES_PASSWORD: catlink
POSTGRES_HOST_AUTH_METHOD: trust
tmpfs:
- /var/lib/postgresql/data
# Redis для кеширования (если потребуется)
- name: redis
image: redis:7-alpine
# Volumes
volumes:
- name: docker
host:
path: /var/run/docker.sock