.gitlab-ci.collabora.yml 3.06 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
32
33
34
# Override the default rules to allow for a regexp match on the upload
upload to obs:
  rules: &lava_upload_rules
    - if: $CI_MERGE_REQUEST_ID
      when: never
    - if: '$CI_COMMIT_BRANCH && $CI_COMMIT_BRANCH =~ /^collabora\/(staging|production)/'

monitor obs:
  rules: *lava_upload_rules

35
36
test:
  stage: test
37
  image: docker:20.10.15-alpine3.15
38
39
40
41
  variables:
    DOCKER_HOST: tcp://docker:2375
    DOCKER_TLS_CERTDIR: ""
  tags:
42
    - heavyweight
43
  services:
44
    - docker:20.10.15-dind
45
46
47
48
  script:
   - apk add --no-cache curl docker-compose
   - docker info
   - docker/collabora/ci-run
49

50
51
build docker image:
  stage: build
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
  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
71
      --destination $CI_REGISTRY_IMAGE/$CI_COMMIT_REF_SLUG:$CI_COMMIT_SHA
72
73
74
      --build-arg REGISTRY=$CI_REGISTRY_IMAGE
      --single-snapshot
    - echo Pushed
75
76
77
78

.deploy:
  stage: deploy
  image:
79
    name: registry.gitlab.collabora.com/sysadmin/ansible-core-services/core-ansible:main
80
81
82
83
    entrypoint: [""]
  tags:
    - lightweight
  script:
84
85
    - "git clone --depth=1 https://gitlab-ci-token:${CI_JOB_TOKEN}@gitlab.collabora.com/sysadmin/ansible-core-services.git"
    - cd ansible-core-services/digital-ocean-k8s && ansible-playbook -e IMAGE_TAG=$CI_COMMIT_SHA IMAGE_TAG= lava-server-staging.yaml
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
  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:
115
    - if: '$CI_COMMIT_BRANCH == "collabora/staging"'
116
117
118
119
120
121
122
123

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