57 lines
1.1 KiB
YAML
57 lines
1.1 KiB
YAML
|
kind: pipeline
|
||
|
type: docker
|
||
|
name: default
|
||
|
|
||
|
steps:
|
||
|
- name: build
|
||
|
image: golang
|
||
|
commands:
|
||
|
- set GOOS=linux
|
||
|
- set GOARCH=amd64
|
||
|
- set CGO_ENABLED=0
|
||
|
- go build -a -ldflags '-extldflags "-static"' -o ${REPO_NAME} cmd/${REPO_NAME}/main.go
|
||
|
|
||
|
- name: test
|
||
|
image: golang
|
||
|
commands:
|
||
|
- go test ./...
|
||
|
|
||
|
- name: scp
|
||
|
image: appleboy/drone-scp
|
||
|
settings:
|
||
|
host:
|
||
|
from_secret: server_ip
|
||
|
username:
|
||
|
from_secret: ssh_user
|
||
|
key:
|
||
|
from_secret: ssh_key
|
||
|
port:
|
||
|
from_secret: ssh_port
|
||
|
target:
|
||
|
- deploys/${REPO_NAME}
|
||
|
source:
|
||
|
- ${REPO_NAME}
|
||
|
- docker-compose.yml
|
||
|
- Dockerfile
|
||
|
rm: true
|
||
|
|
||
|
- name: deploy
|
||
|
image: appleboy/drone-ssh
|
||
|
settings:
|
||
|
host:
|
||
|
from_secret: server_ip
|
||
|
username:
|
||
|
from_secret: ssh_user
|
||
|
key:
|
||
|
from_secret: ssh_key
|
||
|
port:
|
||
|
from_secret: ssh_port
|
||
|
command_timeout: 10s
|
||
|
script:
|
||
|
- cd deploys/${REPO_NAME}
|
||
|
- docker-compose up -d --force-recreate
|
||
|
|
||
|
trigger:
|
||
|
event:
|
||
|
- push
|