.gitlab-ci.collabora.yml 3.15 KB
Newer Older
1
2
stages:
- test
3
4
5
- build
- upload
- OBS
6
7
- deploy
- cleanup
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23

include:
  - project: 'obs/ci-to-obs'
    file: '/ci-to-obs.v1.yml'
    ref: 'main'

build debian source:
  script:
    - mkdir _build
    - VERSION=$(git describe | sed 's,-,.,g').collabora
    - gbp dch --spawn-editor=never -R --ignore-branch -N ${VERSION}-0.1
    - git commit -am "snapshot"
    - git tag debian/${VERSION}-0.1
    - git archive --prefix "lava-${VERSION}/" -o _build/lava_${VERSION}.orig.tar.gz HEAD
    - ls _build/
    - ci-buildpackage -S
24
25
26
27
28
29
30
31

test:
  stage: test
  image: docker
  variables:
    DOCKER_HOST: tcp://docker:2375
    DOCKER_TLS_CERTDIR: ""
  tags:
32
    - heavyweight
33
34
35
36
37
38
  services:
    - docker:dind
  script:
   - apk add --no-cache curl docker-compose
   - docker info
   - docker/collabora/ci-run
39

40
41
build docker image:
  stage: build
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
  image:
    name: gcr.io/kaniko-project/executor:debug-v0.16.0
    entrypoint: [""]
  script:
    - |
      cat << EOF  > /kaniko/.docker/config.json
      {
        "auths":{
          "$CI_REGISTRY": {
            "username":"$CI_REGISTRY_USER",
            "password":"$CI_REGISTRY_PASSWORD"
          }
        }
      }
      EOF
    - >
      /kaniko/executor
      --context $CI_PROJECT_DIR
      --dockerfile $CI_PROJECT_DIR/docker/collabora/Dockerfile
61
      --destination $CI_REGISTRY_IMAGE/$CI_COMMIT_REF_SLUG:$CI_COMMIT_SHA
62
63
64
      --build-arg REGISTRY=$CI_REGISTRY_IMAGE
      --single-snapshot
    - echo Pushed
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115

.deploy:
  stage: deploy
  image:
    name: quay.io/roboll/helmfile:helm3-v0.139.9
    entrypoint: [""]
  tags:
    - lightweight
  script:
    - export GITLAB_APP=$CI_PROJECT_PATH_SLUG
    - export GITLAB_ENVIRONMENT=$CI_ENVIRONMENT_SLUG
    - export HOST=$SERVICE_HOST
    - export LAVA_SERVER_REPOSITORY="$CI_REGISTRY_IMAGE/$CI_COMMIT_REF_SLUG"
    - export LAVA_SERVER_TAG=$CI_COMMIT_SHA
    - export POSTGRESQL_PASSWORD=$(kubectl get secret --ignore-not-found --namespace "$KUBE_NAMESPACE" postgresql -o jsonpath="{.data.postgresql-password}" | base64 -d)
    - |
      export POSTGRES=""
      if [ -n "${POSTGRESQL_PASSWORD}" ] ; then
        export POSTGRES="--set postgresqlPassword=${POSTGRESQL_PASSWORD}"
      fi
    - chmod 0400 ${KUBECONFIG}
    - cd docker/collabora/helm && helmfile --namespace="$KUBE_NAMESPACE" sync ${POSTGRES}
  needs:
    - build docker image

.stop:
  image:
    name: quay.io/roboll/helmfile:helm3-v0.139.9
    entrypoint: [""]
  tags:
    - lightweight
  stage: cleanup
  variables:
    GIT_STRATEGY: none
  script:
    - cd docker/collabora/helm && helmfile --namespace="$KUBE_NAMESPACE" destroy
  environment:
    action: stop


deploy staging:
  extends: .deploy
  variables:
    SERVICE_HOST: "staging.$KUBE_INGRESS_BASE_DOMAIN"
  environment:
    name: $CI_COMMIT_REF_NAME
    url: https://staging.$KUBE_INGRESS_BASE_DOMAIN
    on_stop: stop_staging
  before_script:
    - export SECRET_KEY=$(echo ${STAGING_SECRET_KEY} | base64 -d)
  rules:
116
    - if: '$CI_COMMIT_BRANCH == "collabora/staging"'
117
118
119
120
121
122
123
124

stop_staging:
  stage: cleanup
  extends: .stop
  image: alpine/k8s:1.19.8
  environment:
    name: $CI_COMMIT_REF_NAME
  rules:
125
    - if: '$CI_COMMIT_BRANCH == "collabora/staging"'
126
127
128
      when: manual
  needs:
    - deploy staging