summaryrefslogtreecommitdiff
path: root/.gitlab-ci.yml
blob: deb41236afcfb404cd411fe3feea44f5f5bcd23f (plain)
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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
# When using dind, it's wise to use the overlayfs driver for
# improved performance.
variables:
  DOCKER_DRIVER: overlay2
  MAJOR: 1
  TMP_IMAGE: $CI_REGISTRY_IMAGE/tmp:$CI_COMMIT_SHA

include:
  - template: Container-Scanning.gitlab-ci.yml
  - template: Jobs/Code-Quality.gitlab-ci.yml
  - local: .gitlab/test.yml
  - local: .gitlab/qa.yml
  - local: .gitlab/release.yml

services:
  - docker:stable-dind

stages:
  - build
  - test
  - tag
  - release

build commit:
  image: docker:stable
  stage: build
  script:
    - docker info
    - docker login -u gitlab-ci-token -p $CI_JOB_TOKEN $CI_REGISTRY
    - docker build -t $TMP_IMAGE .
    - docker push $TMP_IMAGE

container_scanning:
  variables:
    CI_APPLICATION_REPOSITORY: $CI_REGISTRY_IMAGE/tmp # only predefined variables are parameter-expanded (no $TMP_IMAGE)

.docker_tag:
  image: docker:stable
  stage: tag
  script:
    - docker info
    - docker login -u gitlab-ci-token -p $CI_JOB_TOKEN $CI_REGISTRY
    - export SOURCE_IMAGE=$TMP_IMAGE
    - export TARGET_IMAGE=$CI_REGISTRY_IMAGE:${IMAGE_TAG:-$CI_JOB_NAME}
    - |
      if [ -z "$DOTENV" ]; then
        docker pull $SOURCE_IMAGE
        docker tag $SOURCE_IMAGE $TARGET_IMAGE
      else
        ./bin/docker-dotenv
      fi
    - docker push $TARGET_IMAGE

branch:
  extends: .docker_tag
  variables:
    IMAGE_TAG: $CI_COMMIT_REF_SLUG
  only:
    - branches
  except:
    - master

edge:
  extends: .docker_tag
  variables:
    IMAGE_TAG: edge
  only:
    - master

version:
  extends: .docker_tag
  before_script:
    - export IMAGE_TAG=${CI_COMMIT_TAG/v/}
    - echo "Checking that $CI_COMMIT_TAG is last in the changelog"
    - test "$(grep '^## v' CHANGELOG.md |head -n 1)" = "## $CI_COMMIT_TAG"
  only:
    - tags
  when: manual
  allow_failure: false