-
Notifications
You must be signed in to change notification settings - Fork 14
/
.drone.yml
35 lines (33 loc) · 1.1 KB
/
.drone.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
kind: pipeline
type: docker
name: default
steps:
- name: go get and build
image: golang:1.18.1
commands:
- |
mkdir -p artifacts
CGO_ENABLED=0 GOPROXY=https://mirrors.aliyun.com/goproxy,direct go build -o artifacts ./...
- name: deploy
image: python:3.6
environment:
SSH_PRIVATE_KEY:
from_secret: SSH_PRIVATE_KEY
SSH_TARGET:
from_secret: SSH_TARGET
SSH_USERNAME:
from_secret: SSH_USERNAME
DEPLOY_PATH:
from_secret: DEPLOY_PATH
commands:
- |
which ssh-agent || ( apt-get update -y && apt-get install openssh-client git -y )
eval $(ssh-agent -s)
echo "$SSH_PRIVATE_KEY" | tr -d '\r' | ssh-add -
mkdir -p ~/.ssh
chmod 700 ~/.ssh
ssh-keyscan $SSH_TARGET >> ~/.ssh/known_hosts
ssh $SSH_USERNAME@$SSH_TARGET "cd $DEPLOY_PATH/../ && docker-compose down"
ssh $SSH_USERNAME@$SSH_TARGET "rm -rf $DEPLOY_PATH/movie-sync-server"
scp artifacts/movie-sync-server $SSH_USERNAME@$SSH_TARGET:$DEPLOY_PATH/
ssh $SSH_USERNAME@$SSH_TARGET "cd $DEPLOY_PATH/ && chmod +x movie-sync-server && cd .. && docker-compose up -d"