Docker building and various fixes around the code.
This commit is contained in:
parent
9893315796
commit
db34a064f5
60
.drone.yml
Normal file
60
.drone.yml
Normal file
@ -0,0 +1,60 @@
|
||||
---
|
||||
kind: pipeline
|
||||
type: docker
|
||||
name: build
|
||||
|
||||
steps:
|
||||
- name: notify-start
|
||||
image: pztrn/discordrone
|
||||
settings:
|
||||
webhook_id:
|
||||
from_secret: discord_webhook_id
|
||||
webhook_token:
|
||||
from_secret: discord_webhook_secret
|
||||
message: 'Starting building **{{repo.name}}#{{build.number}}@{{commit.sha}}** @ {{datetime build.started "02-Jan-2006 15:04:05 MST" "Asia/Yekaterinburg"}} (See {{build.link}} for logs).'
|
||||
|
||||
- name: lint
|
||||
image: golangci/golangci-lint:latest
|
||||
environment:
|
||||
CGO_ENABLED: 0
|
||||
commands:
|
||||
- golangci-lint run
|
||||
|
||||
- name: test
|
||||
image: golang:1.13.1-alpine
|
||||
environment:
|
||||
GOFLAGS: -mod=vendor
|
||||
CGO_ENABLED: 0
|
||||
commands:
|
||||
- go test ./...
|
||||
|
||||
- name: docker
|
||||
image: plugins/docker
|
||||
when:
|
||||
branch:
|
||||
master
|
||||
settings:
|
||||
username:
|
||||
from_secret: dockerhub_user
|
||||
password:
|
||||
from_secret: dockerhub_password
|
||||
repo: pztrn/discordrone
|
||||
auto_tag: true
|
||||
|
||||
- name: notify-end
|
||||
when:
|
||||
status:
|
||||
- success
|
||||
- failure
|
||||
image: pztrn/discordrone
|
||||
settings:
|
||||
webhook_id:
|
||||
from_secret: discord_webhook_id
|
||||
webhook_token:
|
||||
from_secret: discord_webhook_secret
|
||||
message: "
|
||||
{{#success build.status}}
|
||||
**{{repo.name}}#{{build.number}}@{{commit.sha}}** built in {{since build.started}} and pushed to hub.docker.com.
|
||||
{{ else }}
|
||||
**{{repo.name}}#{{build.number}}@{{commit.sha}}** failed. See {{build.link}}.
|
||||
{{/success}}"
|
14
Dockerfile
Normal file
14
Dockerfile
Normal file
@ -0,0 +1,14 @@
|
||||
FROM golang:1.13.1-alpine AS build
|
||||
|
||||
WORKDIR /discordrone
|
||||
COPY . .
|
||||
|
||||
RUN CGO_ENABLED=0 go build -tags netgo -ldflags '-w -extldflags "-static"'
|
||||
|
||||
FROM alpine:3.10
|
||||
LABEL maintainer "Stanislav N. <pztrn@pztrn.name>"
|
||||
|
||||
COPY --from=build /discordrone/discordrone /app/discordrone
|
||||
RUN apk add --no-cache ca-certificates
|
||||
|
||||
ENTRYPOINT [ "/app/discordrone" ]
|
6
env/env.go
vendored
6
env/env.go
vendored
@ -18,13 +18,13 @@ type environmentData struct {
|
||||
Branch string `envconfig:"optional"`
|
||||
Build struct {
|
||||
Action string `envconfig:"optional"`
|
||||
Created int `envconfig:"optional"`
|
||||
Created float64 `envconfig:"optional"`
|
||||
Event string `envconfig:"optional"`
|
||||
Finished int `envconfig:"optional"`
|
||||
Finished float64 `envconfig:"optional"`
|
||||
Link string `envconfig:"optional"`
|
||||
Number int `envconfig:"optional"`
|
||||
Parent string `envconfig:"optional"`
|
||||
Started int `envconfig:"optional"`
|
||||
Started float64 `envconfig:"optional"`
|
||||
Status string `envconfig:"optional"`
|
||||
}
|
||||
CommitHash string `envconfig:"DRONE_COMMIT,optional"`
|
||||
|
@ -35,7 +35,7 @@ type (
|
||||
Title string `json:"title"`
|
||||
Description string `json:"description"`
|
||||
URL string `json:"url"`
|
||||
Color int `json:"color"`
|
||||
Color int64 `json:"color"`
|
||||
Footer EmbedFooterObject `json:"footer"`
|
||||
Author EmbedAuthorObject `json:"author"`
|
||||
Fields []EmbedFieldObject `json:"fields"`
|
||||
|
@ -1,8 +0,0 @@
|
||||
package message
|
||||
|
||||
// stdlib
|
||||
|
||||
// local
|
||||
|
||||
// other
|
||||
//"github.com/drone/drone-template-lib/template"
|
@ -40,7 +40,7 @@ func Process() error {
|
||||
|
||||
// If message was set - format it.
|
||||
if len(env.Data.Plugin.Message) > 0 {
|
||||
text, err := template.RenderTrim(env.Data.Plugin.Message, env.Data)
|
||||
text, err := template.RenderTrim(env.Data.Plugin.Message, env.Data.Drone)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
@ -13,7 +13,7 @@ const (
|
||||
// DroneIconURL default drone logo url
|
||||
droneIconURL = "https://c1.staticflickr.com/5/4236/34957940160_435d83114f_z.jpg"
|
||||
// DroneDesc default drone description
|
||||
droneDesc = "Powered by DiscoDrone Plugin"
|
||||
droneDesc = "Powered by DiscorDrone Plugin"
|
||||
)
|
||||
|
||||
func createEmbed() EmbedObject {
|
||||
@ -54,13 +54,14 @@ func createEmbed() EmbedObject {
|
||||
embed.Description = description
|
||||
|
||||
// Compose color.
|
||||
var color int
|
||||
var color int64
|
||||
if env.Data.Plugin.Color != "" {
|
||||
env.Data.Plugin.Color = strings.Replace(env.Data.Plugin.Color, "#", "", -1)
|
||||
if s, err := strconv.ParseInt(env.Data.Plugin.Color, 16, 32); err == nil {
|
||||
color = int(s)
|
||||
}
|
||||
s, err := strconv.ParseInt(env.Data.Plugin.Color, 16, 32)
|
||||
if err == nil {
|
||||
color = s
|
||||
}
|
||||
} else {
|
||||
|
||||
switch env.Data.Drone.Build.Status {
|
||||
case "success":
|
||||
@ -73,6 +74,8 @@ func createEmbed() EmbedObject {
|
||||
// yellow
|
||||
color = 0xffd930
|
||||
}
|
||||
}
|
||||
|
||||
embed.Color = color
|
||||
|
||||
return embed
|
||||
|
Reference in New Issue
Block a user