From d690424a1dbd1747550088a33302f27c2ead62dd Mon Sep 17 00:00:00 2001 From: Dante Ventieri Date: Mon, 13 Feb 2023 17:50:14 -0300 Subject: [PATCH] Push images to Dockerhub instead of GCR --- .circleci/config.yml | 10 +++++----- Makefile | 11 ++++++++++- 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 7182133..0b137e4 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -31,19 +31,19 @@ jobs: - run: name: Build command: make image - - run: echo "$GCR_JSON_KEY" | docker login -u _json_key --password-stdin us.gcr.io + - run: echo "$DOCKER_PASSWORD" | docker login -u "$DOCKER_USERNAME" --password-stdin - run: - name: Push image to GCR + name: Push image to Dockerhub command: | - docker tag codeclimate/codeclimate-sonar-php \ - us.gcr.io/code-climate/codeclimate-sonar-php:b$CIRCLE_BUILD_NUM - docker push us.gcr.io/code-climate/codeclimate-sonar-php:b$CIRCLE_BUILD_NUM + make release RELEASE_TAG="b$CIRCLE_BUILD_NUM" + make release RELEASE_TAG="$(echo $CIRCLE_BRANCH | grep -oP 'channel/\K[\w\-]+')" workflows: version: 2 build_deploy: jobs: - build - release_images: + context: Quality requires: - build filters: diff --git a/Makefile b/Makefile index ca557f7..fe9955e 100644 --- a/Makefile +++ b/Makefile @@ -1,9 +1,18 @@ -.PHONY: image test +.PHONY: image test release IMAGE_NAME ?= codeclimate/codeclimate-sonar-php +RELEASE_REGISTRY ?= codeclimate + +ifndef RELEASE_TAG +override RELEASE_TAG = latest +endif image: docker build --rm -t $(IMAGE_NAME) . test: image docker run --rm -ti -w /usr/src/app -u root $(IMAGE_NAME) gradle clean test + +release: + docker tag $(IMAGE_NAME) $(RELEASE_REGISTRY)/codeclimate-sonar-php:$(RELEASE_TAG) + docker push $(RELEASE_REGISTRY)/codeclimate-sonar-php:$(RELEASE_TAG)