diff --git a/.drone.yml b/.drone.yml new file mode 100644 index 0000000..bb41aeb --- /dev/null +++ b/.drone.yml @@ -0,0 +1,36 @@ +kind: pipeline +name: default + +steps: + - name: linter + image: golang:latest + environment: + GOPROXY: https://mirrors.aliyun.com/goproxy/ + commands: + - go get -u github.com/golangci/golangci-lint/cmd/golangci-lint + - golangci-lint run + + - name: build + image: golang:latest + environment: + GOPROXY: https://mirrors.aliyun.com/goproxy/ + GOOS: linux + GOARCH: amd64 + CGO_ENABLED: 0 + commands: + - go build -o demo-app + + - name: docker + image: plugins/docker + settings: + registry: docker.gitee.ltd + repo: docker.gitee.ltd/lxh/golang-demo + use_cache: true + username: docker + password: dockeruser + tags: + - latest + - 0.0.1 + when: + event: push + branch: master \ No newline at end of file diff --git a/go.mod b/go.mod new file mode 100644 index 0000000..3b6047c --- /dev/null +++ b/go.mod @@ -0,0 +1,3 @@ +module drone-ci-golang + +go 1.13 diff --git a/main.go b/main.go new file mode 100644 index 0000000..e871e59 --- /dev/null +++ b/main.go @@ -0,0 +1,23 @@ +package main + +import ( + "net/http" + + "github.com/gin-gonic/gin" + "github.com/sirupsen/logrus" +) + +func main() { + r := gin.Default() + + r.GET("/health", func(c *gin.Context) { + c.JSON(http.StatusOK, gin.H { + "health": true, + }) + }) + + if err := r.Run(":8080"); err != nil { + logrus.WithError(err).Fatal("Couldn't listen") + } + +}