butler/build/ci/.drone.yml

85 lines
2.1 KiB
YAML
Raw Normal View History

2023-08-13 17:34:58 +00:00
kind: pipeline
type: docker
name: default
steps:
2023-08-13 20:10:45 +00:00
- name: test
2023-08-13 17:45:31 +00:00
pull: if-not-exists
2023-08-13 17:39:55 +00:00
image: golang:1.20
2023-08-13 17:34:58 +00:00
commands:
2023-08-13 20:10:45 +00:00
- go test ./...
2023-08-13 17:34:58 +00:00
2023-08-13 20:10:45 +00:00
- name: build
pull: if-not-exists
image: golang:1.20
2023-09-12 16:50:22 +00:00
environment:
TELEGRAM_TOKEN:
from_secret: TELEGRAM_TOKEN
POSTGRES_URL_CONNECT:
from_secret: POSTGRES_URL_CONNECT
settings:
envs: [ TELEGRAM_TOKEN,POSTGRES_URL_CONNECT ]
2023-08-13 17:34:58 +00:00
commands:
2023-09-12 17:56:55 +00:00
- CGO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo -o butler cmd/butler/main.go
2023-09-12 16:24:10 +00:00
- touch .env
2023-09-12 16:50:22 +00:00
- echo TELEGRAM_TOKEN=$${TELEGRAM_TOKEN} >> .env
- echo POSTGRES_URL_CONNECT=$${POSTGRES_URL_CONNECT} >> .env
2023-09-12 16:24:10 +00:00
- name: copy to server
pull: if-not-exists
image: appleboy/drone-scp
settings:
host:
2023-09-12 16:32:12 +00:00
from_secret: SSH_IP
2023-09-12 16:24:10 +00:00
username:
2023-09-12 16:32:12 +00:00
from_secret: SSH_USER
2023-09-12 16:24:10 +00:00
key:
2023-09-12 16:32:12 +00:00
from_secret: SSH_KEY
2023-09-12 16:24:10 +00:00
port:
2023-09-12 16:32:12 +00:00
from_secret: SSH_PORT
2023-09-12 16:24:10 +00:00
target: /home/crab/deploys/butler_bot
source:
- .env
2023-09-12 16:45:44 +00:00
- build/ci/Dockerfile
2023-09-12 16:50:22 +00:00
- deploy/docker-compose.yml
2023-09-12 16:24:10 +00:00
- migrations
2023-09-12 16:56:04 +00:00
- butler
2023-09-12 16:24:10 +00:00
rm: true
2023-09-12 16:56:04 +00:00
- name: deploy
pull: if-not-exists
image: appleboy/drone-ssh
2023-09-13 11:32:55 +00:00
environment:
DB_PASS:
from_secret: DB_PASS
2023-09-12 16:56:04 +00:00
settings:
host:
from_secret: SSH_IP
username:
from_secret: SSH_USER
key:
from_secret: SSH_KEY
port:
from_secret: SSH_PORT
2023-09-13 11:32:55 +00:00
envs: [ DB_PASS ]
2023-09-12 16:56:04 +00:00
script:
2023-09-12 16:58:07 +00:00
- cd /home/crab/deploys/butler_bot
2023-09-13 00:29:14 +00:00
- cp /etc/ssl/certs/ca-certificates.crt .
2023-09-12 16:56:04 +00:00
- mv build/ci/Dockerfile .
- mv deploy/docker-compose.yml .
- rm -r build deploy
2023-09-13 16:18:52 +00:00
- touch migrate.sh
2023-09-13 16:23:31 +00:00
- echo goose -allow-missing -dir ./migrations postgres \"user=crab password=$${DB_PASS} dbname=butler host=localhost port=5432 sslmode=disable\" up >> migrate.sh
2023-09-13 16:18:52 +00:00
- chmod +x migrate.sh
- ./migrate.sh
# - goose -allow-missing -dir ./migrations postgres "user=crab password=$${DB_PASS} dbname=butler host=localhost port=5432 sslmode=disable" up
2023-09-13 11:32:55 +00:00
- docker-compose up -d --force-recreate
2023-08-13 20:10:45 +00:00
# TODO:
2023-09-13 16:18:52 +00:00
# run migrations
2023-08-13 17:34:58 +00:00
trigger:
event:
- push