Commit ed69c952 authored by Pantelis Malekas's avatar Pantelis Malekas
Browse files

feat: add deploy and workflow stages

parent 31493927
Loading
Loading
Loading
Loading
Loading
+72 −2
Original line number Diff line number Diff line
@@ -3,8 +3,8 @@ stages:
  - test
  - analyze
  - dev_image_build
  #- dev_deploy
  #- dev_workflows
  - dev_deploy
  - dev_workflows
  - develop_image_tag
  - validate_main_source
  - release
@@ -143,6 +143,76 @@ dev_image_build_job:
  rules:
    - if: '$CI_PIPELINE_SOURCE == "merge_request_event" && $CI_MERGE_REQUEST_TARGET_BRANCH_NAME == "develop"'


dev_deploy_job:
  stage: dev_deploy
  tags:
    - hypo
  image:
    name: labs.etsi.org:5050/osl/hypo/code/org.etsi.osl.hypo.ops/cicd/integration.tests/python-argocd:3.9
    pull_policy: [always, if-not-present]
  before_script:
    - mkdir -p /tmp/bin
    - export PATH="/tmp/bin:$PATH"
    - curl -L -o /tmp/age.tar.gz https://github.com/FiloSottile/age/releases/download/v1.2.1/age-v1.2.1-linux-amd64.tar.gz
    - tar -xzf /tmp/age.tar.gz -C /tmp
    - mv /tmp/age/age /tmp/age/age-keygen /tmp/bin/
    - curl -L -o /tmp/bin/sops https://github.com/getsops/sops/releases/download/v3.10.2/sops-v3.10.2.linux.amd64
    - chmod +x /tmp/bin/sops
    - sops --version
    - age --version
    - git clone --depth 1 --branch gitops-cd https://oauth2:$GROUP_ACCESS_TOKEN@$INSTALLER_REPO
    - cd $INSTALLER_PATH
    - echo "$SOPS_AGE_KEY_PRIVATE" > ~/.sops-age-key.txt
    - chmod 600 ~/.sops-age-key.txt
    - export SOPS_AGE_KEY_FILE=~/.sops-age-key.txt

  script:
    - sops --decrypt charts/hypo/values-cd.enc.yaml > charts/hypo/values-cd.yaml
    - python3 scripts/helm_update_etsi.py $CI_REGISTRY_IMAGE/$IMAGE_NAME:$CI_COMMIT_SHORT_SHA $DEV_TMF_API_IMAGE $DEV_SONATA_OSS_IMAGE $DEV_SONATA_CORE_IMAGE  $DEV_PORTAL_CART_IMAGE $DEV_TELEMETRY_IMAGE $DEV_PEERING_IMAGE $DEV_REGISTRY_IMAGE $DEV_FABRIC_IMAGE $DEV_PORTAL $DEV_SONATA_HELM_IMAGE
    - sops --encrypt --age $SOPS_AGE_KEY_PUBLIC charts/hypo/values-cd.yaml > charts/hypo/values-cd.enc.yaml
    - rm -f charts/hypo/values-cd.yaml ~/.sops-age-key.txt
    - git add charts/hypo/values-cd.enc.yaml
    - git config --global user.email "$GITLAB_USER_EMAIL"
    - git config --global user.name "$GITLAB_USER_NAME"

    - |
      if git commit -m "Update values.yaml for GitOps CD [skip ci]"; then
        git push origin gitops-cd
      else
        echo "No changes to commit."
      fi

    - |
      set -e
      argocd login "$ARGOCD_SERVER" --username "$ARGOCD_USERNAME" --password "$ARGOCD_PASSWORD" --insecure
      argocd app get hypo --refresh >/dev/null
      argocd app wait hypo --sync --health --timeout 120
      echo "Argo CD application 'hypo' is synced and healthy."
  dependencies:
     - dev_image_build_job
  rules:
     - if: '$CI_PIPELINE_SOURCE == "merge_request_event" && $CI_MERGE_REQUEST_TARGET_BRANCH_NAME == "develop"'


dev_workflows_job:
  stage: dev_workflows
  tags:
    - hypo
  image: labs.etsi.org:5050/osl/hypo/code/org.etsi.osl.hypo.ops/cicd/integration.tests/maven:3.9-eclipse-temurin-17
  before_script:
    # clone the integration tests repo
    - git clone --depth 1 --branch develop "https://oauth2:$GROUP_ACCESS_TOKEN@$INTEGRATION_REPO"
    - cd integration.tests
  script:
    - mvn -B -q test "-Dkarate.env=$KARATE_ENV" "-Dkarate.options=--tags @smoke-e2e-workflow-private"
  dependencies:
    - dev_deploy_job
  rules:
    - if: '$CI_PIPELINE_SOURCE == "merge_request_event" && $CI_MERGE_REQUEST_TARGET_BRANCH_NAME == "develop"'



develop_image_tag_job:
  stage: develop_image_tag
  tags: