128 lines
2.7 KiB
YAML
128 lines
2.7 KiB
YAML
---
|
|
kind: pipeline
|
|
type: docker
|
|
name: CI
|
|
|
|
steps:
|
|
- name: LINT
|
|
image: golangci/golangci-lint
|
|
volumes:
|
|
- name: cache
|
|
path: /go
|
|
environment:
|
|
GOMODCACHE: '/go/mod'
|
|
GOCACHE: '/go/cache'
|
|
commands:
|
|
- go fmt ./...
|
|
- golangci-lint run ./... --timeout=10m --verbose
|
|
|
|
- name: TEST
|
|
image: golang
|
|
volumes:
|
|
- name: cache
|
|
path: /go
|
|
environment:
|
|
GOMODCACHE: '/go/mod'
|
|
GOCACHE: '/go/cache'
|
|
commands:
|
|
- go test ./...
|
|
depends_on:
|
|
- LINT
|
|
|
|
- name: BUILD
|
|
image: plugins/docker
|
|
workspace:
|
|
path: /
|
|
settings:
|
|
repo: registry.spasskiy.site/gerald
|
|
dockerfile: ./Dockerfile
|
|
tags: [ "latest" ]
|
|
username:
|
|
from_secret: docker_username
|
|
password:
|
|
from_secret: docker_password
|
|
registry: registry.spasskiy.site
|
|
depends_on:
|
|
- LINT
|
|
- TEST
|
|
|
|
- name: NOTIFY_TG
|
|
image: appleboy/drone-telegram
|
|
settings:
|
|
token:
|
|
from_secret: telegram_token
|
|
to: "-605857722"
|
|
message: >
|
|
{{#success build.status}}
|
|
*[Gerald]* ✅ Build *{{build.number}}* on branch *{{commit.branch}}* tested successfully.
|
|
{{else}}
|
|
*[Gerlad]* 🚧 Build *{{build.number}}* on branch *{{commit.branch}}* failed.
|
|
{{/success}}
|
|
*msg:* {{commit.message}}
|
|
depends_on:
|
|
- LINT
|
|
- TEST
|
|
- BUILD
|
|
|
|
volumes:
|
|
- name: cache
|
|
host:
|
|
path: /var/lib/cache
|
|
|
|
trigger:
|
|
event:
|
|
- push
|
|
|
|
---
|
|
kind: pipeline
|
|
type: docker
|
|
name: CD-STAGE
|
|
|
|
steps:
|
|
- name: DEPLOY-PROD
|
|
image: appleboy/drone-ssh:1.6.4
|
|
environment:
|
|
POSTGRES_DSN:
|
|
from_secret: POSTGRES_DSN
|
|
APNS_KEY:
|
|
from_secret: APNS_KEY
|
|
settings:
|
|
host: 68.183.14.242
|
|
username: root
|
|
password:
|
|
from_secret: ssh_password
|
|
script:
|
|
- cd ~/gerald && git checkout master && git pull
|
|
- cd ~/gerald/deploy && docker-compose pull gerald
|
|
- docker-compose up -d pg traefik
|
|
- POSTGRES_DSN=$POSTGRES_DSN docker-compose up -d --force-recreate --no-deps --build gerald
|
|
when:
|
|
target:
|
|
- production
|
|
|
|
- name: NOTIFY-TG
|
|
image: appleboy/drone-telegram
|
|
settings:
|
|
token:
|
|
from_secret: telegram_token
|
|
to: "-605857722"
|
|
message: >
|
|
{{#success build.status}}
|
|
*[2phon]* 🚀 Build {{build.number}} *deployed* on *production*.
|
|
{{else}}
|
|
*[2phon]* ❌ Build {{build.number}} failed to deploy on *production*.
|
|
{{/success}}
|
|
*commit msg:* {{commit.message}}
|
|
depends_on:
|
|
- DEPLOY-PROD
|
|
when:
|
|
target:
|
|
- production
|
|
|
|
trigger:
|
|
event:
|
|
- promote
|
|
target:
|
|
- staging
|
|
- production
|