From b18a04d041aa4ef632ec29895b0cee6fea63f3b9 Mon Sep 17 00:00:00 2001 From: GitLab Bot Date: Wed, 19 Apr 2023 02:38:12 +0000 Subject: Add latest changes from gitlab-org/gitlab@15-10-stable-ee --- .gitlab/ci/release-environments/main.gitlab-ci.yml | 32 +++++++++++++++++++ scripts/construct-release-environments-versions.rb | 37 ++++++++++++++++++++++ 2 files changed, 69 insertions(+) create mode 100755 scripts/construct-release-environments-versions.rb diff --git a/.gitlab/ci/release-environments/main.gitlab-ci.yml b/.gitlab/ci/release-environments/main.gitlab-ci.yml index e2fed0a6dbd..982329646a7 100644 --- a/.gitlab/ci/release-environments/main.gitlab-ci.yml +++ b/.gitlab/ci/release-environments/main.gitlab-ci.yml @@ -4,6 +4,7 @@ default: stages: - prepare + - deploy include: - local: .gitlab/ci/global.gitlab-ci.yml @@ -56,7 +57,38 @@ release-environments-build-cng: GITLAB_SHELL_VERSION: "${GITLAB_SHELL_VERSION}" GITALY_SERVER_VERSION: "${GITALY_SERVER_VERSION}" RUBY_VERSION: "${FULL_RUBY_VERSION}" + IMAGE_TAG_EXT: "-${CI_COMMIT_SHORT_SHA}" trigger: project: gitlab-org/build/CNG-mirror branch: $TRIGGER_BRANCH strategy: depend + +release-environments-deploy-env: + allow_failure: true + stage: deploy + needs: ["release-environments-build-cng"] + variables: + DEPLOY_ENV: deploy.env + script: + - ./scripts/construct-release-environments-versions.rb > $DEPLOY_ENV + artifacts: + reports: + dotenv: $DEPLOY_ENV + paths: + - $DEPLOY_ENV + expire_in: 7 days + when: always + +release-environments-deploy: + allow_failure: true + stage: deploy + needs: ["release-environments-deploy-env"] + inherit: + variables: false + variables: + VERSIONS: "${VERSIONS}" + ENVIRONMENT: "${ENVIRONMENT}" + trigger: + project: gl-infra/release-environments + branch: main + strategy: depend diff --git a/scripts/construct-release-environments-versions.rb b/scripts/construct-release-environments-versions.rb new file mode 100755 index 00000000000..1af45923731 --- /dev/null +++ b/scripts/construct-release-environments-versions.rb @@ -0,0 +1,37 @@ +#!/usr/bin/env ruby +# frozen_string_literal: true + +require 'json' + +class ReleaseEnvironmentsModel + COMPONENTS = %w[gitaly registry kas mailroom pages gitlab shell].freeze + + # Will generate a json object that has a key for every component and a value which is the environment combined with + # short sha + # Example: + # { + # "gitaly": "15-10-stable-c7c5131c", + # "registry": "15-10-stable-c7c5131c", + # "kas": "15-10-stable-c7c5131c", + # "mailroom": "15-10-stable-c7c5131c", + # "pages": "15-10-stable-c7c5131c", + # "gitlab": "15-10-stable-c7c5131c", + # "shell": "15-10-stable-c7c5131c" + # } + def generate_json(environment) + output_json = {} + COMPONENTS.each do |component| + output_json[component.to_s] = "#{environment}-#{ENV['CI_COMMIT_SHORT_SHA']}" + end + JSON.generate(output_json) + end +end + +# Outputs in `dotenv` format the ENVIRONMENT and VERSIONS to pass to release environments e.g. +# ENVIRONMENT=15-10-stable +# VERSIONS={"gitaly":"15-10-stable-c7c5131c","registry":"15-10-stable-c7c5131c","kas":"15-10-stable-c7c5131c", ... +if $PROGRAM_NAME == __FILE__ + environment = ENV['CI_COMMIT_REF_SLUG'].sub("-ee", "") + puts "ENVIRONMENT=#{environment}" + puts "VERSIONS=#{ReleaseEnvironmentsModel.new.generate_json(environment)}" +end -- cgit v1.2.1