wkws/.gitlab-ci.yml

49 lines
1.0 KiB
YAML

stages:
- test
- build
- deploy
.go-cache:
variables:
GOPATH: $CI_PROJECT_DIR/.go
before_script:
- mkdir -p .go
cache:
paths:
- .go/pkg/mod/
format:
image: golang:latest
stage: test
extends: .go-cache
script:
- go fmt $(go list ./... | grep -v /vendor/)
- go vet $(go list ./... | grep -v /vendor/)
- go test -race $(go list ./... | grep -v /vendor/)
build:
image: golang:latest
stage: build
extends: .go-cache
script:
- mkdir -p out/production/WKWS
- CGO_ENABLED=0 go build -o out/production/WKWS/app ./main.go
artifacts:
name: "server"
paths:
- out/
container-image:
image: docker:stable
stage: deploy
dependencies:
- build
services:
- name: docker:dind
alias: docker
before_script:
- docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY
script:
- docker build --tag $CI_REGISTRY_IMAGE:$CI_COMMIT_SHA --tag $CI_REGISTRY_IMAGE:latest .
- docker push $CI_REGISTRY_IMAGE:$CI_COMMIT_SHA
- docker push $CI_REGISTRY_IMAGE:latest