Skip to content

Commit

Permalink
добавил github actions
Browse files Browse the repository at this point in the history
  • Loading branch information
mxssl committed Dec 20, 2019
1 parent ac86fd1 commit 6e8a636
Show file tree
Hide file tree
Showing 12 changed files with 111 additions and 445 deletions.
1 change: 1 addition & 0 deletions .github/FUNDING.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
custom: https://www.buymeacoffee.com/ydfPU75
32 changes: 32 additions & 0 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: "Release"

on:
push:
tags:
- '*'

jobs:
docker-release:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- name: Docker login
run: docker login --username ${{ secrets.DOCKER_LOGIN }} --password ${{ secrets.DOCKER_PASSWORD }}
- name: Docker release
run: make docker-release

github-release:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- name: Set up Go
uses: actions/setup-go@master
with:
go-version: 1.13.5
- name: Run GoReleaser
uses: goreleaser/goreleaser-action@v1
with:
version: latest
args: release --rm-dist
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
20 changes: 20 additions & 0 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
before:
hooks:
- go mod download
builds:
- env:
- CGO_ENABLED=0
goos:
- linux
goarch:
- amd64
checksum:
name_template: 'checksums.txt'
snapshot:
name_template: "{{ .Tag }}"
changelog:
sort: asc
filters:
exclude:
- '^docs:'
- '^test:'
17 changes: 12 additions & 5 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,18 +1,25 @@
FROM golang:alpine as builder
FROM golang:1.13.5-alpine3.10 as builder

ENV GO111MODULE=on

WORKDIR /go/src/github.com/mxssl/selectel_billing_exporter
COPY . .

# install external depends
RUN apk add --no-cache ca-certificates curl git
RUN CGO_ENABLED=0 GOOS=`go env GOHOSTOS` GOARCH=`go env GOHOSTARCH` go build -o app
RUN apk add --no-cache \
ca-certificates \
curl \
git
RUN CGO_ENABLED=0 \
GOOS=`go env GOHOSTOS` \
GOARCH=`go env GOHOSTARCH` \
go build -v -mod=vendor -o app

# Copy compiled binary to clear Alpine Linux image
FROM alpine:latest
FROM alpine:3.11.0
WORKDIR /
RUN apk add --no-cache ca-certificates
RUN apk add --no-cache \
ca-certificates
COPY --from=builder /go/src/github.com/mxssl/selectel_billing_exporter .
RUN chmod +x app
CMD ["./app"]
35 changes: 21 additions & 14 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,34 +1,41 @@
BINARY_NAME=app
CURRENT_DIR=$(shell pwd)
TAG=$(shell git name-rev --tags --name-only $(shell git rev-parse HEAD))
DOCKER_REGISTRY=mxssl
export GO111MODULE=on

.PHONY: all build clean lint critic test dep
.PHONY: all build clean lint critic test

all: build

build:
go build -o ${BINARY_NAME} -v
chmod +x app
go build -v -mod=vendor -o ${BINARY_NAME}

clean:
rm -f ${BINARY_NAME}

lint:
golangci-lint run

critic:
gocritic check-project ${CURRENT_DIR}
golangci-lint run -v

test:
go test -v ./...

init:
GO111MODULE=on go mod init

vendor:
GO111MODULE=on go mod vendor
go mod init

tidy:
GO111MODULE=on go mod tidy
go mod tidy

github-release-dry:
@echo "TAG: ${TAG}"
goreleaser release --rm-dist --snapshot --skip-publish

github-release:
@echo "TAG: ${TAG}"
goreleaser release --rm-dist

run:
GO111MODULE=on go run main.go
docker-release:
@echo "Registry: ${DOCKER_REGISTRY}"
@echo "TAG: ${TAG}"
docker build --tag ${DOCKER_REGISTRY}/selectel_billing_exporter:${TAG} .
docker push ${DOCKER_REGISTRY}/selectel_billing_exporter:${TAG}
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ version: '3'
services:
exporter:
build: .
image: mxssl/selectel_billing_exporter
image: mxssl/selectel_billing_exporter:0.0.1
ports:
- "6789:80"
restart: always
Expand Down
2 changes: 1 addition & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ services:
selectel_billing_exporter:
container_name: selectel_billing_exporter
build: .
image: mxssl/selectel_billing_exporter:latest
image: mxssl/selectel_billing_exporter:0.0.1
ports:
- "6789:80"
restart: always
Expand Down
2 changes: 2 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,5 @@ require (
github.com/prometheus/procfs v0.0.0-20181129180645-aa55a523dc0a // indirect
golang.org/x/sync v0.0.0-20181108010431-42b317875d0f // indirect
)

go 1.13
223 changes: 0 additions & 223 deletions vendor/github.com/prometheus/client_golang/prometheus/promauto/auto.go

This file was deleted.

Loading

0 comments on commit 6e8a636

Please sign in to comment.