.gitlab-ci.yml 2.99 KB
Newer Older
Pascal's avatar
Pascal committed
1
image: docker:19.03.0
2 3 4 5 6

stages:
  - build
  - test
  - release
7
  - trigger
8 9 10 11 12 13

# When using dind, it's wise to use the overlayfs driver for
# improved performance.
variables:
  DOCKER_DRIVER: overlay2
  DOCKER_REGISTRY: docker-registry.kronova.net
Pascal's avatar
Pascal committed
14
  DOCKER_TLS_CERTDIR: ""
15
  CONTAINER_TEST: docker-registry.kronova.net/docker/typo3-php:$CI_COMMIT_BRANCH
16 17 18 19 20 21 22 23
  CONTAINER_DOCKERHUB_BRANCH: kronova/typo3-php:$CI_COMMIT_BRANCH
  CONTAINER_DOCKERHUB_LATEST: kronova/typo3-php:latest
  CONTAINER_DOCKERHUB_TAG: kronova/typo3-php:$CI_COMMIT_TAG

cache:
  key: ${CI_COMMIT_REF_SLUG}
  paths:
    - ./.build
Pascal's avatar
Pascal committed
24

25
services:
Pascal's avatar
Pascal committed
26
  - docker:19.03.0-dind
27 28

before_script:
Pascal's avatar
Pascal committed
29
  - echo "$CI_BUILD_TOKEN" | docker login --username gitlab-ci-token $DOCKER_REGISTRY --password-stdin
30 31 32 33

build:
  stage: build
  script:
34
    - docker build -t $CONTAINER_TEST .
35
    # todo: remove the gitlab container registry completely and use docker hub only
36
    - docker push $CONTAINER_TEST
37
    - mkdir -p ./.build
38
    - docker save $CONTAINER_TEST -o ./.build/image.tar
39 40
  only:
    - master
41
    - /^php-.*$/
42

43
.test:
44
  stage: test
45 46 47
  before_script:
    # use gitlab-ci cache instead of container registry to bypass the slow pull
    - docker load < ./.build/image.tar || true
48 49
  only:
    - master
50
    - /^php-.*$/
51

52 53
test-php:
  extends: .test
54
  script:
55
    - docker load < ./.build/image.tar || true
56
    - docker run $CONTAINER_TEST php -v
57 58 59 60

test-typo3_8:
  extends: .test
  script:
61
    - docker run $CONTAINER_TEST composer require typo3/minimal '^8'
62 63 64 65

test-typo3_9:
  extends: .test
  script:
66
    - docker run $CONTAINER_TEST composer require typo3/minimal '^9'
67 68

test-imagemagick:
69
  extends: .test
70
  script:
71
    - docker run $CONTAINER_TEST convert -version
72

73
push-on-dockerhub:
74
  stage: release
75
  before_script: []
76
  script:
77 78
    - docker pull $CONTAINER_TEST
    - docker tag $CONTAINER_TEST $CONTAINER_DOCKERHUB_LATEST
79 80 81
    - docker logout
    - echo "$REGISTRY_PASSWORD" | docker login --username "$REGISTRY_USER" --password-stdin
    - docker push $CONTAINER_DOCKERHUB_LATEST
82 83
  only:
    - master
84 85
  allow_failure: false
  when: manual
86

87
push-tag-on-dockerhub:
88
  stage: release
89
  before_script: []
90
  script:
91 92
    - docker pull $CONTAINER_TEST
    - docker tag $CONTAINER_TEST $CONTAINER_DOCKERHUB_TAG
93 94 95
    - docker logout
    - echo "$REGISTRY_PASSWORD" | docker login --username "$REGISTRY_USER" --password-stdin
    - docker push $CONTAINER_DOCKERHUB_TAG
96 97 98
  only:
    - tags

99
push-branch-on-dockerhub:
100
  stage: release
101
  before_script: []
102
  script:
103 104
    - docker pull $CONTAINER_TEST
    - docker tag $CONTAINER_TEST $CONTAINER_DOCKERHUB_BRANCH
Pascal's avatar
Pascal committed
105 106
    - docker logout
    - echo "$REGISTRY_PASSWORD" | docker login --username "$REGISTRY_USER" --password-stdin
107 108 109 110 111
    - docker push $CONTAINER_DOCKERHUB_BRANCH
  only:
    - /^php-.*$/
  except:
    - tags
112 113

trigger-typo3-utilities:
Pascal's avatar
Pascal committed
114
  image: kronova/typo3-utilities
115 116
  stage: trigger
  before_script:
Pascal Rinker's avatar
Pascal Rinker committed
117
    - ''
118
  script:
Pascal's avatar
Pascal committed
119
    - "curl -X POST -F token=d5403e897bd63d9d2213f6febe3921 -F ref=master https://git.kronova.net/api/v4/projects/42/trigger/pipeline"
120 121
  only:
    - master