-
Notifications
You must be signed in to change notification settings - Fork 0
/
.gitlab-ci.yml
60 lines (51 loc) · 1.7 KB
/
.gitlab-ci.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
image: docker:git
services:
- docker:dind
variables:
REPO_NAME: gitlab.com/nolith/codeclimate-gocyclo
APPLICATION_REPOSITORY: $CI_REGISTRY_IMAGE/$CI_COMMIT_REF_SLUG
APPLICATION_TAG: $CI_COMMIT_SHA
DOCKER_DRIVER: overlay2
stages:
- build
- test
- release
.docker_build: &docker_build
script:
- docker build -t "$APPLICATION_REPOSITORY:$APPLICATION_TAG" .
- '[[ -n "$CI_REGISTRY_USER" ]] && docker login -u "$CI_REGISTRY_USER" -p "$CI_REGISTRY_PASSWORD" "$CI_REGISTRY"'
- docker push "$APPLICATION_REPOSITORY:$APPLICATION_TAG"
.docker_release: &docker_release
stage: release
variables:
RELEASE_REPOSITORY: $CI_REGISTRY_IMAGE
RELEASE_TAG: latest
script:
- docker pull "$APPLICATION_REPOSITORY:$APPLICATION_TAG"
- docker tag "$APPLICATION_REPOSITORY:$APPLICATION_TAG" "$RELEASE_REPOSITORY:$RELEASE_TAG"
- '[[ -n "$CI_REGISTRY_USER" ]] && docker login -u "$CI_REGISTRY_USER" -p "$CI_REGISTRY_PASSWORD" "$CI_REGISTRY"'
- docker push "$RELEASE_REPOSITORY:$RELEASE_TAG"
docker_image:
<<: *docker_build
stage: build
codequality:
stage: test
script:
- docker pull "$APPLICATION_REPOSITORY:$APPLICATION_TAG"
- docker tag "$APPLICATION_REPOSITORY:$APPLICATION_TAG" codeclimate/codeclimante-gocyclo
- docker run --env CODECLIMATE_CODE="$PWD" --volume "$PWD":/code --volume /var/run/docker.sock:/var/run/docker.sock --volume /tmp/cc:/tmp/cc codeclimate/codeclimate analyze -f json | tee codeclimate.json
artifacts:
paths: [codeclimate.json]
expire_in: 1 week
docker tagged image:
<<: *docker_release
variables:
RELEASE_TAG: $CI_COMMIT_TAG
only:
- tags
promote to latest:
<<: *docker_release
only:
- tags
- master
when: manual