From 2bf49c405b693bf554bfa5929b1b5f36884eaac5 Mon Sep 17 00:00:00 2001 From: Piotr Biernat Date: Thu, 21 Apr 2022 22:39:44 +0200 Subject: [PATCH] [fix] CI/CD fixes --- .drone.yml | 12 +++++++++--- deploy/build_image.sh | 14 +++++--------- deploy/publish_image.sh | 17 ++++++----------- 3 files changed, 20 insertions(+), 23 deletions(-) diff --git a/.drone.yml b/.drone.yml index 7bac05b..34aaa66 100644 --- a/.drone.yml +++ b/.drone.yml @@ -3,7 +3,7 @@ type: docker name: default steps: -- name: static_check +- name: go_static_check image: golang:latest commands: - go install honnef.co/go/tools/cmd/staticcheck@latest @@ -12,7 +12,7 @@ steps: - name: gopath path: /go -- name: lint +- name: go_lint image: golang:latest commands: - go install golang.org/x/lint/golint@latest @@ -21,7 +21,7 @@ steps: - name: gopath path: /go -- name: vet +- name: go_vet image: golang:latest commands: - go vet ./pkg/... @@ -34,6 +34,10 @@ steps: commands: - sleep 5 - ./deploy/build_image.sh + depends_on: + - go_static_check + - go_lint + - go_vet volumes: - name: docker-sock path: /var/run @@ -47,6 +51,8 @@ steps: from_secret: registry_password commands: - ./deploy/publish_image.sh + depends_on: + - build_image volumes: - name: docker-sock path: /var/run diff --git a/deploy/build_image.sh b/deploy/build_image.sh index f4d560b..365c9ea 100755 --- a/deploy/build_image.sh +++ b/deploy/build_image.sh @@ -1,14 +1,10 @@ #!/bin/sh -set -e -set -x +set -evx -# 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) && +branch=${DRONE_TAG:=$CI_COMMIT_BRANCH} +branch=$(echo $branch | grep -v /) || echo $branch ; +p1=$(echo $branch | cut -d / -f1 -s) && +p2=$(echo $branch | cut -d / -f2 -s) && tag=${branch:=$p1-$p2} && echo "Building" $tag diff --git a/deploy/publish_image.sh b/deploy/publish_image.sh index 28aefb1..cc9e21a 100755 --- a/deploy/publish_image.sh +++ b/deploy/publish_image.sh @@ -1,16 +1,11 @@ #!/bin/sh -set -e -set -x +set -evx -# 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} && +branch=${DRONE_TAG:=$CI_COMMIT_BRANCH} +branch=$(echo $branch | grep -v /) || echo $branch ; +p1=$(echo $branch | cut -d / -f1 -s) && +p2=$(echo $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 &&