diff --git a/.drone.yml b/.drone.yml index 58d316e..ac1585f 100644 --- a/.drone.yml +++ b/.drone.yml @@ -3,42 +3,37 @@ type: docker name: default steps: -# - name: static_check -# image: golang:1.18 -# commands: -# - go install honnef.co/go/tools/cmd/staticcheck@latest -# - staticcheck ./pkg/... -# volumes: -# - name: gopath -# path: /go +- name: static_check + image: golang:1.18 + commands: + - go install honnef.co/go/tools/cmd/staticcheck@latest + - staticcheck ./pkg/... + volumes: + - name: gopath + path: /go -# - name: lint -# image: golang:1.18 -# commands: -# - go install golang.org/x/lint/golint@latest -# - golint -set_exit_status ./pkg/... -# volumes: -# - name: gopath -# path: /go +- name: lint + image: golang:1.18 + commands: + - go install golang.org/x/lint/golint@latest + - golint -set_exit_status ./pkg/... + volumes: + - name: gopath + path: /go -# - name: vet -# image: golang:1.18 -# commands: -# - go vet ./pkg/... -# volumes: -# - name: gopath -# path: /go +- name: vet + image: golang:1.18 + commands: + - go vet ./pkg/... + volumes: + - name: gopath + path: /go - name: build_image image: plugins/docker commands: - - ./test.sh - # - branch=$(echo $CI_COMMIT_BRANCH | grep -v '/') || echo $CI_COMMIT_BRANCH - # - p1=$(echo $CI_COMMIT_BRANCH | cut -d '/' -f1 -s) - # - p2=$(echo $CI_COMMIT_BRANCH | cut -d '/' -f2 -s) - # - tag=${branch:-$p1-$p2} - # - echo $tag - # - docker build -t git.pbiernat.dev/golang/vegvisir:$tag -f Dockerfile.build . + - sleep 5 + - ./deploy/build_image.sh volumes: - name: docker-sock path: /var/run @@ -51,13 +46,7 @@ steps: DOCKER_PASSWORD: from_secret: registry_password commands: - - branch=$(echo $CI_COMMIT_BRANCH | grep -v '/') || echo $CI_COMMIT_BRANCH - - p1=$(echo $CI_COMMIT_BRANCH | cut -d '/' -f1 -s) - - p2=$(echo $CI_COMMIT_BRANCH | cut -d '/' -f2 -s) - - tag=${branch:=$p1-$p2} - - echo $tag - - echo $DOCKER_PASSWORD | docker login git.pbiernat.dev -u $DOCKER_USERNAME --password-stdin && - - docker push git.pbiernat.dev/golang/vegvisir:$tag + - ./deploy/publish_image.sh volumes: - name: docker-sock path: /var/run diff --git a/Dockerfile.build b/deploy/Dockerfile.build similarity index 100% rename from Dockerfile.build rename to deploy/Dockerfile.build diff --git a/Dockerfile.run b/deploy/Dockerfile.run similarity index 100% rename from Dockerfile.run rename to deploy/Dockerfile.run diff --git a/deploy/build_image.sh b/deploy/build_image.sh new file mode 100755 index 0000000..f4d560b --- /dev/null +++ b/deploy/build_image.sh @@ -0,0 +1,15 @@ +#!/bin/sh +set -e +set -x + +# BRANCH="dev/ci-docker-builder" +# BRANCH="develop" +# BRANCH=$CI_COMMIT_BRANCH + +branch=$(echo $CI_COMMIT_BRANCH | grep -v /) || echo $CI_COMMIT_BRANCH ; +p1=$(echo $CI_COMMIT_BRANCH | cut -d / -f1 -s) && +p2=$(echo $CI_COMMIT_BRANCH | cut -d / -f2 -s) && +tag=${branch:=$p1-$p2} && +echo "Building" $tag + +docker build -t git.pbiernat.dev/golang/vegvisir:$tag -f deploy/Dockerfile.build . diff --git a/deploy/publish_image.sh b/deploy/publish_image.sh new file mode 100755 index 0000000..28aefb1 --- /dev/null +++ b/deploy/publish_image.sh @@ -0,0 +1,17 @@ +#!/bin/sh +set -e +set -x + +# BRANCH="dev/ci-docker-builder" +# BRANCH="develop" +# BRANCH=$CI_COMMIT_BRANCH + + +branch=$(echo $CI_COMMIT_BRANCH | grep -v /) || echo $CI_COMMIT_BRANCH ; +p1=$(echo $CI_COMMIT_BRANCH | cut -d / -f1 -s) && +p2=$(echo $CI_COMMIT_BRANCH | cut -d / -f2 -s) && +tag=${branch:=$p1-$p2} && +echo "Publishing" $tag + +echo $DOCKER_PASSWORD | docker login git.pbiernat.dev -u $DOCKER_USERNAME --password-stdin && +docker push git.pbiernat.dev/golang/vegvisir:$tag diff --git a/test.sh b/test.sh deleted file mode 100755 index afe66e2..0000000 --- a/test.sh +++ /dev/null @@ -1,28 +0,0 @@ -#!/bin/sh -set -e -set -x - -# BRANCH="dev/ci-docker-builder" -BRANCH="develop" - -simple=$(echo $BRANCH | grep -v '/') || echo $BRANCH -p1=$(echo $BRANCH | cut -d '/' -f1 -s) -p2=$(echo $BRANCH | cut -d '/' -f2 -s) -tag=${simple:-$p1-$p2} -echo $tag - -# p1=$(echo "develop" | grep -s '/') && echo "1: $p1" -# p2=$(echo "develop/fix" | grep -s '/') && echo "2: $p2" -# p3=$(echo "develop" | grep -s -v '/') && echo "3: $p3" -# p4=$(echo "develop/fix" | grep -s -v '/') && echo "4: $p4" - -# echo $p1 $p2 $p3 $p4 -# echo "DONE" - - -#simple=$(echo $BRANCH | grep -v '/') ; -#p1=$(echo $BRANCH | cut -d '/' -f1 -s) ; -#p2=$(echo $BRANCH | cut -d '/' -f2 -s) ; -#tag=${simple:=$p1-$p2} && - -#echo "TAG:" $tag