-
Notifications
You must be signed in to change notification settings - Fork 0
/
.drone.yml.backup
65 lines (60 loc) · 2.21 KB
/
.drone.yml.backup
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
workspace:
base: /go
path: src/github.com/udistrital/${DRONE_REPO##udistrital/}
when:
branch: [master, develop]
pipeline:
# build and test the go program
go:
image: golang:1.9
commands:
- go get -t
- GOOS=linux GOARCH=amd64 go build -o main
when:
branch: [master, develop]
# build and push docker image to docker hub
publish_dockerhub:
image: plugins/docker
repo: oas0/${DRONE_REPO##udistrital/}
secrets: [ docker_username, docker_password ]
tag:
- ${DRONE_COMMIT:0:7}
- latest
when:
branch: [master, develop]
# Update service ECS (Elastic Container Service) in AWS
go-awsecs:
image: golang:1.9
secrets: [ aws_access_key_id, aws_secret_access_key ]
commands:
- case ${DRONE_BRANCH} in
develop) AMBIENTE=preprod ;;
master) AMBIENTE=prod ;;
esac
- AWS_REGION=us-east-1
- CLUSTER=oas
- SERVICE=${DRONE_REPO##udistrital/}_$AMBIENTE
- MYCONTAINER=oas0/${DRONE_REPO##udistrital/}:${DRONE_COMMIT:0:7}
- container_name=${DRONE_REPO##udistrital/}
- go get -v -u -t github.com/udistrital/go-awsecs/cmd/update-aws-ecs-service
- AWS_ACCESS_KEY_ID=$${AWS_ACCESS_KEY_ID} AWS_SECRET_ACCESS_KEY=$${AWS_SECRET_ACCESS_KEY} AWS_REGION=$AWS_REGION
$GOPATH/bin/update-aws-ecs-service -cluster $CLUSTER -service $SERVICE -container-image $container_name=$MYCONTAINER
when:
branch: [master, develop]
#Notify results to telegram
#telegram_token is the bot token and telegram_to is the group id that start with "-" character
notify_telegram:
image: appleboy/drone-telegram
secrets: [ telegram_token, telegram_to ]
format: html
message: >
{{#success build.status}}
<code>{{repo.owner}}/{{repo.name}}</code> <a href="{{build.link}}">SUCCESS</a>
<code>{{commit.branch}}</code>@<a href="{{commit.link}}">{{truncate commit.sha 7}}</a>
{{else}}
<code>{{repo.owner}}/{{repo.name}}</code> <a href="{{build.link}}">FAILURE</a>
<code>{{commit.branch}}</code>@<a href="{{commit.link}}">{{truncate commit.sha 7}}</a>
{{/success}}
when:
status: [success, failure]
branch: [master, develop]