diff --git a/capif/.gitlab-ci.yml b/capif/.gitlab-ci.yml index 397b06cdb3159d572e9c7d0c0342ef2021269cc9..12fdf28a24310be5ca5ff717b11fe839af6066d1 100644 --- a/capif/.gitlab-ci.yml +++ b/capif/.gitlab-ci.yml @@ -61,18 +61,18 @@ variables: tags: - docker-in-docker -.staging_common: &staging_common - only: - - merge_requests - except: - variables: - - $CI_MERGE_REQUEST_TARGET_BRANCH_NAME != "staging" - tags: - - shell +#.staging_common: &staging_common +# only: +# - merge_requests +# except: +# variables: +# - $CI_MERGE_REQUEST_TARGET_BRANCH_NAME != "staging" +# tags: +# - shell# -.dev_common: &dev_common - tags: - - shell +#.dev_common: &dev_common +# tags: +# - shell #main_cancel_previous_action: # stage: main_pre_pipeline diff --git a/capif/templates/cd-deploy-ocf.gitlab-ci.yml b/capif/templates/cd-deploy-ocf.gitlab-ci.yml index d051f67c5a0a8dbe0b8bd74d51a857aaae67500e..66bb81246c5b743ad71d6f13b45f49c101451aa8 100644 --- a/capif/templates/cd-deploy-ocf.gitlab-ci.yml +++ b/capif/templates/cd-deploy-ocf.gitlab-ci.yml @@ -1,4 +1,5 @@ stages: + - deploy_ocf_oficial_staging - deploy_ocf_staging - delete_ocf_staging - deploy_ocf_dev @@ -18,43 +19,37 @@ variables: VAULT_ACCESS_TOKEN: $VAULT_ACCESS_TOKEN CI_REGISTRY: $CI_REGISTRY -.main_common: &main_common +.staging_common: &staging_common only: - merge_requests except: variables: -# - $CI_MERGE_REQUEST_TARGET_BRANCH_NAME != "main" - $CI_MERGE_REQUEST_TARGET_BRANCH_NAME != "staging" tags: - shell -.staging_common: &staging_common - only: - - merge_requests - except: - variables: - - $CI_MERGE_REQUEST_TARGET_BRANCH_NAME != "staging" +.staging_post_mr: &staging_post_mr tags: - shell + rules: + - if: '$CI_COMMIT_REF_NAME == "staging"' .dev_common: &dev_common tags: - shell + +## staging before mr ### deploy_ocf_staging: stage: deploy_ocf_staging needs: - staging_build_and_push <<: *staging_common environment: - name: review/staging + name: review/dev_to_staging url: https://capif-$CI_ENVIRONMENT_SLUG.$DOMAIN_STAGING on_stop: delete_ocf_staging auto_stop_in: 3 day -# rules: -# - if: $CI_COMMIT_BRANCH == "main" -# when: never -# - if: $CI_COMMIT_BRANCH == "staging" script: - | helm version @@ -113,12 +108,74 @@ delete_ocf_staging: <<: *staging_common script: - echo "### deleting environment $NAMESPACE_STAGING###" -# - helm uninstall -n $NAMESPACE_STAGING ocf-staging + - helm uninstall -n $NAMESPACE_DEV ocf-staging when: manual environment: - name: review/staging + name: review/dev_to_staging action: stop +### staging branch merged ### +deploy_ocf_oficial_staging: + stage: deploy_ocf_oficial_staging + needs: + - staging_build_and_push_mr + <<: *staging_common + environment: + name: review/oficial-staging + url: https://capif-staging.$DOMAIN_STAGING + script: + - | + helm version + kubectl version --output=yaml + echo "### setting kubeconfig###" + whoami + kubectl cluster-info + yq --version + ls -rtt helm/capif + cat helm/capif/Chart.yaml + yq e -i ".appVersion = \"$IMAGE_TAG_STAGING\"" helm/capif/Chart.yaml + cat helm/capif/Chart.yaml + echo "### download dependencies###" + helm dependency build helm/capif + echo "### updating capif###" + helm upgrade --install -n $NAMESPACE_STAGING ocf-staging helm/capif/ --set nginx.nginx.env.capifHostname=capif-staging.$DOMAIN_STAGING \ + --set nginx.nginx.env.registerHostname=register-staging.$DOMAIN_STAGING \ + --set monitoring.grafana.ingress.hosts[0].host="grafana-staging.$DOMAIN_STAGING" \ + --set monitoring.grafana.ingress.hosts[0].paths[0].path="/" \ + --set monitoring.grafana.ingress.hosts[0].paths[0].pathType="Prefix" \ + --set monitoring.grafana.env.prometheusURL=http://prometheus.ocf.pre-production \ + --set tempo.tempo.metricsGenerator.remoteWriteUrl=http://prometheus.ocf.pre-production/api/v1/write \ + --set parametersVault.env.vaultHostname=$VAULT_HOSTNAME \ + --set parametersVault.env.vaultPort=$VAULT_PORT \ + --set parametersVault.env.vaultAccessToken=$VAULT_ACCESS_TOKEN \ + --set ingress.ip=10.43.107.132 \ + --set accessControlPolicy.image.repository=$CI_REGISTRY/ocf/capif/staging/ocf-access-control-policy-api \ + --set accessControlPolicy.image.tag=staging \ + --set apiInvocationLogs.apiInvocationLogs.image.repository=$CI_REGISTRY/ocf/capif/staging/ocf-logging-api-invocation-api \ + --set apiInvocationLogs.apiInvocationLogs.image.tag=staging \ + --set apiInvokerManagement.apiInvokerManagement.image.repository=$CI_REGISTRY/ocf/capif/staging/ocf-api-invoker-management-api \ + --set apiInvokerManagement.apiInvokerManagement.image.tag=staging \ + --set apiProviderManagement.apiProviderManagement.image.repository=$CI_REGISTRY/ocf/capif/staging/ocf-api-provider-management-api \ + --set apiProviderManagement.apiProviderManagement.image.tag=staging \ + --set capifEvents.capifEvents.image.repository=$CI_REGISTRY/ocf/capif/staging/ocf-events-api \ + --set capifEvents.capifEvents.image.tag=staging \ + --set capifRoutingInfo.capifRoutingInfo.image.repository=$CI_REGISTRY/ocf/capif/staging/ocf-routing-info-api \ + --set capifRoutingInfo.capifRoutingInfo.image.tag=staging \ + --set capifSecurity.capifSecurity.image.repository=$CI_REGISTRY/ocf/capif/staging/ocf-security-api \ + --set capifSecurity.capifSecurity.image.tag=staging \ + --set register.register.image.repository=$CI_REGISTRY/ocf/capif/staging/register \ + --set register.register.image.tag=staging \ + --set logs.logs.image.repository=$CI_REGISTRY/ocf/capif/staging/ocf-auditing-api \ + --set logs.logs.image.tag=staging \ + --set nignx.nginx.image.repository=$CI_REGISTRY/ocf/capif/staging/nginx \ + --set nignx.nginx.image.tag=staging \ + --set publishedApis.publishedApis.image.repository=$CI_REGISTRY/ocf/capif/staging/ocf-publish-service-api \ + --set publishedApis.publishedApis.image.tag=staging \ + --set serviceApis.serviceApis.image.repository=$CI_REGISTRY/ocf/capif/staging/ocf-discover-service-api \ + --set serviceApis.serviceApis.image.tag=staging \ + --set nginx.nginx.image.repository=$CI_REGISTRY/ocf/capif/staging/nginx \ + --set nginx.nginx.image.tag=staging --wait --timeout=10m --create-namespace + ## dev ### deploy_ocf_dev: stage: deploy_ocf_dev diff --git a/capif/templates/ci_staging.gitlab-ci.yml b/capif/templates/ci_staging.gitlab-ci.yml index e5ec93b4ffefb4b5407067c36d85ac92ace68de3..c4f69dcf33d37ee83700e4e031fefccd0e2027bb 100644 --- a/capif/templates/ci_staging.gitlab-ci.yml +++ b/capif/templates/ci_staging.gitlab-ci.yml @@ -7,6 +7,7 @@ stages: - staging_unit_tests - staging_security - staging_build_and_push + - staging_build_and_push_mr variables: CI_JOB_TOKEN: $CI_JOB_TOKEN @@ -16,14 +17,18 @@ variables: CAPIF_DOCKER_REGISTRY: $CAPIF_DOCKER_REGISTRY .staging_common: &staging_common - only: - - merge_requests - except: - variables: - - $CI_MERGE_REQUEST_TARGET_BRANCH_NAME != "staging" + rules: + - if: '$CI_PIPELINE_SOURCE == "merge_request_event" && $CI_MERGE_REQUEST_TARGET_BRANCH_NAME == "staging"' tags: - shell +.staging_mr: &staging_mr + rules: + - if: '$CI_PIPELINE_SOURCE == "push" && $CI_COMMIT_REF_NAME == "staging"' + tags: + - shell + + .staging_dnd: &staging_dnd allow_failure: true rules: @@ -324,3 +329,85 @@ staging_build_and_push: - echo "----------------------------------------------------" - docker logout $CI_REGISTRY <<: *staging_common + +### staging branch merged ### +staging_build_and_push_mr: + stage: staging_build_and_push_mr + script: + - export TMP_PWD=$PWD + - echo "TMP_PWD=$TMP_PWD" + - echo "### docker login###" + - docker login --username $CI_REGISTRY_USER --password $CAPIF_DOCKER_REGISTRY $CI_REGISTRY + - echo "----------------------------------------------------" + - echo "### build and push nginx image###" + - cd $TMP_PWD/services/nginx/ + - docker build -t $CI_REGISTRY/ocf/capif/staging/nginx:staging . + - docker push $CI_REGISTRY/ocf/capif/staging/nginx:staging + - echo "----------------------------------------------------" + - echo "### build and push register image###" + - cd $TMP_PWD/services/register/ + - docker build -t $CI_REGISTRY/ocf/capif/staging/register:staging . + - docker push $CI_REGISTRY/ocf/capif/staging/register:staging + - echo "----------------------------------------------------" + - echo "### build and push TS29222_CAPIF_Access_Control_Policy_API image###" + - cd $TMP_PWD/services/TS29222_CAPIF_Access_Control_Policy_API/ + - docker build -t $CI_REGISTRY/ocf/capif/staging/ocf-access-control-policy-api:staging . + - docker push $CI_REGISTRY/ocf/capif/staging/ocf-access-control-policy-api:staging + - echo "----------------------------------------------------" + - echo "### build and push TS29222_CAPIF_API_Invoker_Management_API image###" + - cd $TMP_PWD/services/TS29222_CAPIF_API_Invoker_Management_API/ + - docker build -t $CI_REGISTRY/ocf/capif/staging/ocf-api-invoker-management-api:staging . + - docker push $CI_REGISTRY/ocf/capif/staging/ocf-api-invoker-management-api:staging + - echo "----------------------------------------------------" + - echo "### build and push TS29222_CAPIF_API_Provider_Management_API image###" + - cd $TMP_PWD/services/TS29222_CAPIF_API_Provider_Management_API/ + - docker build -t $CI_REGISTRY/ocf/capif/staging/ocf-api-provider-management-api:staging . + - docker push $CI_REGISTRY/ocf/capif/staging/ocf-api-provider-management-api:staging + - echo "----------------------------------------------------" + - echo "### build and push TS29222_CAPIF_Auditing_API image###" + - cd $TMP_PWD/services/TS29222_CAPIF_Auditing_API/ + - docker build -t $CI_REGISTRY/ocf/capif/staging/ocf-auditing-api:staging . + - docker push $CI_REGISTRY/ocf/capif/staging/ocf-auditing-api:staging + - echo "----------------------------------------------------" + - echo "### build and push TS29222_CAPIF_Discover_Service_API image###" + - cd $TMP_PWD/services/TS29222_CAPIF_Discover_Service_API/ + - docker build -t $CI_REGISTRY/ocf/capif/staging/ocf-discover-service-api:staging . + - docker push $CI_REGISTRY/ocf/capif/staging/ocf-discover-service-api:staging + - echo "----------------------------------------------------" + - echo "### build and push TS29222_CAPIF_Events_API image###" + - cd $TMP_PWD/services/TS29222_CAPIF_Events_API/ + - docker build -t $CI_REGISTRY/ocf/capif/staging/ocf-events-api:staging . + - docker push $CI_REGISTRY/ocf/capif/staging/ocf-events-api:staging + - echo "----------------------------------------------------" + - echo "### build and push TS29222_CAPIF_Logging_API_Invocation_API image###" + - cd $TMP_PWD/services/TS29222_CAPIF_Logging_API_Invocation_API/ + - docker build -t $CI_REGISTRY/ocf/capif/staging/ocf-logging-api-invocation-api:staging . + - docker push $CI_REGISTRY/ocf/capif/staging/ocf-logging-api-invocation-api:staging + - echo "----------------------------------------------------" + - echo "### build and push TS29222_CAPIF_Publish_Service_API image###" + - cd $TMP_PWD/services/TS29222_CAPIF_Publish_Service_API/ + - docker build -t $CI_REGISTRY/ocf/capif/staging/ocf-publish-service-api:staging . + - docker push $CI_REGISTRY/ocf/capif/staging/ocf-publish-service-api:staging + - echo "----------------------------------------------------" + - echo "### build and push TS29222_CAPIF_Routing_Info_API image###" + - cd $TMP_PWD/services/TS29222_CAPIF_Routing_Info_API/ + - docker build -t $CI_REGISTRY/ocf/capif/staging/ocf-routing-info-api:staging . + - docker push $CI_REGISTRY/ocf/capif/staging/ocf-routing-info-api:staging + - echo "----------------------------------------------------" + - echo "### build and push TS29222_CAPIF_Security_API image###" + - cd $TMP_PWD/services/TS29222_CAPIF_Security_API/ + - docker build -t $CI_REGISTRY/ocf/capif/staging/ocf-security-api:staging . + - docker push $CI_REGISTRY/ocf/capif/staging/ocf-security-api:staging + - echo "----------------------------------------------------" + - echo "### build and push vault image###" + - cd $TMP_PWD/services/vault/ + - docker build -t $CI_REGISTRY/ocf/capif/staging/vault:staging . + - docker push $CI_REGISTRY/ocf/capif/staging/vault:staging + - echo "----------------------------------------------------" + - echo "### build and push helper image###" + - cd $TMP_PWD/services/helper/ + - docker build -t $CI_REGISTRY/ocf/capif/staging/helper:staging . + - docker push $CI_REGISTRY/ocf/capif/staging/helper:staging + - echo "----------------------------------------------------" + - docker logout $CI_REGISTRY + <<: *staging_mr \ No newline at end of file