Skip to content

Push images to Dockerhub instead of GCR (rubocop-1-39-0) #343

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 16, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,25 +25,25 @@ jobs:
circleci step halt
fi
- run: 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 $CIRCLE_PROJECT_USERNAME/$CIRCLE_PROJECT_REPONAME \
us.gcr.io/code-climate/codeclimate-rubocop:b$CIRCLE_BUILD_NUM
docker push us.gcr.io/code-climate/codeclimate-rubocop: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:
- test
- release_images:
context: Quality
requires:
- test
filters:
branches:
only: /master|channel\/[\w-]+/
notify:
webhooks:
- url: https://cc-slack-proxy.herokuapp.com/circle
- url: https://cc-slack-proxy.herokuapp.com/circle
13 changes: 11 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
.PHONY: image test docs bundle
.PHONY: image test docs bundle release

IMAGE_NAME ?= codeclimate/codeclimate-rubocop
RELEASE_REGISTRY ?= codeclimate

ifndef RELEASE_TAG
override RELEASE_TAG = latest
endif
Comment on lines +6 to +8
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
ifndef RELEASE_TAG
override RELEASE_TAG = latest
endif
RELEASE_TAG ?= latest

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@fede-moya this sadly does not work when providing an empty string. Makefile takes empty strings as not null, so it'll end up not tagging the image as latest. The ifndef workaround lets us provide an empty string that will still be replaced with latest


image:
docker build --rm -t $(IMAGE_NAME) .
Expand All @@ -19,4 +24,8 @@ bundle:
docker run --rm \
--entrypoint /bin/sh \
--volume $(PWD):/usr/src/app \
$(IMAGE_NAME) -c "cd /usr/src/app && bundle $(BUNDLE_ARGS)"
$(IMAGE_NAME) -c "cd /usr/src/app && bundle $(BUNDLE_ARGS)"

release:
docker tag $(IMAGE_NAME) $(RELEASE_REGISTRY)/codeclimate-rubocop:$(RELEASE_TAG)
docker push $(RELEASE_REGISTRY)/codeclimate-rubocop:$(RELEASE_TAG)