diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index c10ee44998aed205e02aae20991bd095c30fde40..415bbffa61e31461cb3e6472ae785f1b1b40d054 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -28,3 +28,40 @@ lint: reports: junit: golangci-output.xml expire_in: 7 days + +build-binary: + image: golang:1-alpine + stage: build + before_script: + - go version + script: + - >- + CGO_ENABLED=0 + go build + -v + -o webhook + -ldflags '-w -s -extldflags "-static"' + . + artifacts: + paths: + - webhook + +build-image: + image: alpine:3 + stage: deploy + needs: + - build + before_script: + - apk --no-cache add buildah ca-certificates-bundle + - >- + buildah login + --username "$CI_REGISTRY_USER" + --password "$CI_REGISTRY_PASSWORD" + "$CI_REGISTRY" + script: + - ctr=$(buildah from scratch) + - buildah copy $ctr /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/ca-certificates.crt + - buildah copy $ctr webhook /webhook + - buildah config --entrypoint '["/webhook"]' $ctr + - buildah commit --squash $ctr $CI_REGISTRY_IMAGE:exp-$CI_COMMIT_SHA + - buildah push $CI_REGISTRY_IMAGE:exp-$CI_COMMIT_SHA