forked from Securing-DevOps/deployer
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcircle.yml
60 lines (54 loc) · 2.12 KB
/
circle.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
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
# These environment variables must be set in CircleCI UI
#
# DOCKER_EMAIL - login info for docker hub
# DOCKER_USER
# DOCKER_PASS
#
# Read the README for more information.
machine:
environment:
GOPATH_HEAD: "$(echo $GOPATH | cut -d ':' -f 1)"
GOPATH_BASE: "$GOPATH_HEAD/src/github.com/$CIRCLE_PROJECT_USERNAME"
GO15VENDOREXPERIMENT: 1
DOCKER_REPO: "$(if [ $CIRCLE_PROJECT_USERNAME == 'Securing-DevOps' ]; then echo securingdevops; else echo $DOCKER_USER; fi)"
services:
- docker
dependencies:
override:
- rm -rf ${GOPATH_BASE}/
- mkdir -p "$GOPATH_BASE"
- mkdir -p "$GOPATH/bin"
- cp -r ${HOME}/${CIRCLE_PROJECT_REPONAME} ${GOPATH_BASE}/
- go get github.com/govend/govend
- sudo pip install awscli
test:
override:
- >
go test
github.com/${CIRCLE_PROJECT_USERNAME}/${CIRCLE_PROJECT_REPONAME}
# Go applications in the busybox container must be built statically
- >
go install --ldflags '-extldflags "-static"'
github.com/${CIRCLE_PROJECT_USERNAME}/${CIRCLE_PROJECT_REPONAME}
- '[ ! -e bin ] && mkdir bin'
- cp "$GOPATH_HEAD/bin/${CIRCLE_PROJECT_REPONAME}" bin/deployer
- chmod +x deploymentTests/*
- docker build -t ${DOCKER_REPO}/${CIRCLE_PROJECT_REPONAME} .
# Run GOVEND to check if outdated dependencies are present
- 'GOPATH="$GOPATH_HEAD"; ( cd ${GOPATH_BASE}/${CIRCLE_PROJECT_REPONAME} && govend -u && git diff --quiet )'
deployment:
hub_latest:
# appropriately tag and push the container to dockerhub
# only when on the master branch
branch: "master"
commands:
- >
docker login -e ${DOCKER_EMAIL}
-u ${DOCKER_USER} -p ${DOCKER_PASS}
# write the sha256 sum to an artifact to make image verification easier
- >
docker images --no-trunc | awk '/^app/ {print $3}' |
tee $CIRCLE_ARTIFACTS/docker-image-shasum256.txt
- docker push ${DOCKER_REPO}/${CIRCLE_PROJECT_REPONAME}
# trigger ebs redeploy
- aws elasticbeanstalk update-environment --region us-east-1 --application-name invoicer201707071231 --environment-id e-h4vyur8nup --version-label deployer-api