Skip to content
Snippets Groups Projects
.gitlab-ci.yml 3.13 KiB
Newer Older
  - remote: https://open.greenhost.net/stackspin/stackspin/-/raw/main/.gitlab/ci_templates/helm_package.yml
Varac's avatar
Varac committed
  - remote: https://open.greenhost.net/stackspin/stackspin/-/raw/main/.gitlab/ci_templates/dummy_job.yml
  - template: 'Workflows/MergeRequest-Pipelines.gitlab-ci.yml'
  image:
    name: alpine/k8s:1.22.6
    entrypoint: ["/bin/sh", "-c"]
  before_script:
    - kubectl config get-contexts
    - kubectl config use-context stackspin/kubernetes-agent-setup:stackspin-k8s-agent

Maarten de Waard's avatar
Maarten de Waard committed
      - taiko-tests/**/*.js
      - values-local.yaml.example
      - values.yaml
      - Chart.yaml
Varac's avatar
Varac committed
      - .gitlab-ci.yml
.delete_helmrelease:
  stage: install-helm-chart
  script:
    - cd ${CHART_DIR:-"."}
    - ./fully-delete-helmrelease.sh "nc$CI_MERGE_REQUEST_IID" "nc$CI_MERGE_REQUEST_IID"
    - kubectl delete namespace "nc$CI_MERGE_REQUEST_IID"
  extends:
    - .use_kubernetes
    - .chart_changes_rules

  - install-helm-chart
  - test-helm-chart
  - package-helm-chart
  - release-helm-chart
Varac's avatar
Varac committed
  - dummy
variables:
  CHART_NAME: nextcloud-onlyoffice
pre-install-delete-helmrelease:
  # This job will fail if a helmrelease didn't exist (yet). For example in a
  # first pipeline for an MR.
  allow_failure: true

# This will clean up helmreleases after MRs have been merged, or after some time
post-install-delete-helmrelease:
  extends:
    - .delete_helmrelease
  # Gets triggered by on_stop of install-helmrelease, or manually
  when: manual
  environment:
install-helmrelease:
  stage: install-helm-chart
  needs:
    # This job contains the `helm dep` artifacts
    - job: lint-helm
    # We can't install if there's still an installation from a previous run
    # present.
    - job: pre-install-delete-helmrelease
  script:
    - cd ${CHART_DIR:-"."}
    - cp values-local.yaml.example values-ci.yaml
    # This sets the domains to files-MR_ID.gitlab.stackspin.net and
    # office-MR_ID.gitlab.stackspin.net
    - sed -i "s/\.your\.domain/-nc$CI_MERGE_REQUEST_IID.gitlab.stackspin.net/" values-ci.yaml
    # Make sure TLS certificate secrets for different MRs do not clash
    - sed -i "s/files-cert/files-cert-nc$CI_MERGE_REQUEST_IID/" values-ci.yaml
    - sed -i "s/office-cert/office-cert-nc$CI_MERGE_REQUEST_IID/" values-ci.yaml
Varac's avatar
Varac committed
    - kubectl get namespace "nc$CI_MERGE_REQUEST_IID" && kubectl delete namespace "nc$CI_MERGE_REQUEST_IID"
    - kubectl create namespace "nc$CI_MERGE_REQUEST_IID"
    - helm install -n nc$CI_MERGE_REQUEST_IID --wait "nc$CI_MERGE_REQUEST_IID" . -f values-ci.yaml
    name: helmrelease/nc$CI_MERGE_REQUEST_IID
    url: https://files-nc$CI_MERGE_REQUEST_IID.gitlab.stackspin.net
    on_stop: post-install-delete-helmrelease

test-helm-chart:
  stage: test-helm-chart
  script:
    - cd ${CHART_DIR:-"."}
    - helm test -n nc$CI_MERGE_REQUEST_IID --logs "nc$CI_MERGE_REQUEST_IID"