Created
February 16, 2019 19:08
-
-
Save brpaz/6d0da1d18ebfa9fe3ef936b3096afb55 to your computer and use it in GitHub Desktop.
#gitlab #docker
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
image: golang:1.11 | |
variables: | |
TEST_IMAGE: $CI_REGISTRY_IMAGE:$CI_COMMIT_SHORT_SHA | |
RELEASE_CI_REGISTRY: registry.hub.docker.com | |
RELEASE_IMAGE: $RELEASE_CI_REGISTRY/brpaz/gitlab-mr-commenter:$CI_COMMIT_TAG | |
RELEASE_IMAGE_LATEST: $RELEASE_CI_REGISTRY/brpaz/gitlab-mr-commenter:latest | |
stages: | |
- test | |
- build | |
- release | |
lint_code: | |
stage: test | |
script: | |
- go get golang.org/x/lint/golint | |
- make lint | |
only: | |
- branches | |
unit_tests: | |
stage: test | |
script: | |
- make dep | |
only: | |
- branches | |
build-image: | |
stage: build | |
image: docker:latest | |
services: | |
- docker:dind | |
script: | |
# push the test image to GitLab CI registry | |
- echo $CI_JOB_TOKEN | docker login --username gitlab-ci-token --password-stdin $CI_REGISTRY | |
- docker build -t $TEST_IMAGE . | |
- docker push $TEST_IMAGE | |
only: | |
- branches | |
release: | |
stage: release | |
image: docker:latest | |
services: | |
- docker:dind | |
script: | |
# Push the final tagged image to Docker Hub. | |
- echo $CI_JOB_TOKEN | docker login --username gitlab-ci-token --password-stdin $CI_REGISTRY | |
- docker pull ${TEST_IMAGE} | |
- echo $DOCKERHUB_PASSWORD | docker login --username $DOCKERHUB_USER --password-stdin $RELEASE_CI_REGISTRY | |
- docker tag ${TEST_IMAGE} ${RELEASE_IMAGE} | |
- docker push ${RELEASE_IMAGE} | |
- docker tag ${TEST_IMAGE} ${RELEASE_IMAGE_LATEST} | |
- docker push ${RELEASE_IMAGE_LATEST} | |
only: | |
- tags |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment