CI: Provide a Drone promotion to build the build-container (#71133)

This commit is contained in:
Emil Tullstedt
2023-07-11 13:08:05 +02:00
committed by GitHub
parent b5272b5160
commit 7a9847e196
4 changed files with 121 additions and 1 deletions

View File

@@ -9,11 +9,16 @@ load(
load(
"scripts/drone/vault.star",
"from_secret",
"gcp_download_build_container_assets_key",
)
load(
"scripts/drone/utils/windows_images.star",
"windows_images",
)
load(
"scripts/drone/utils/images.star",
"images",
)
def publish_ci_windows_test_image_pipeline():
trigger = {
@@ -65,3 +70,51 @@ def publish_ci_windows_test_image_pipeline():
}
return [pl]
def publish_ci_build_container_image_pipeline():
trigger = {
"event": ["promote"],
"target": ["ci-build-container-image"],
}
pl = pipeline(
name = "publish-ci-build-container-image",
trigger = trigger,
edition = "",
steps = [
{
"name": "validate-version",
"image": images["alpine_image"],
"commands": [
"if [ -z \"${BUILD_CONTAINER_VERSION}\" ]; then echo Missing BUILD_CONTAINER_VERSION; false; fi",
],
},
{
"name": "download-macos-sdk",
"image": images["cloudsdk_image"],
"environment": {
"GCP_KEY": from_secret(gcp_download_build_container_assets_key),
},
"commands": [
"printenv GCP_KEY > /tmp/key.json",
"gcloud auth activate-service-account --key-file=/tmp/key.json",
"gsutil cp gs://grafana-private-downloads/MacOSX10.15.sdk.tar.xz ./scripts/build/ci-build/MacOSX10.15.sdk.tar.xz",
],
},
{
"name": "build-and-publish", # Consider splitting the build and the upload task.
"image": images["cloudsdk_image"],
"volumes": [{"name": "docker", "path": "/var/run/docker.sock"}],
"environment": {
"DOCKER_USERNAME": from_secret("docker_username"),
"DOCKER_PASSWORD": from_secret("docker_password"),
},
"commands": [
"printenv DOCKER_PASSWORD | docker login -u \"$DOCKER_USERNAME\" --password-stdin",
"docker build -t \"grafana/build-container:${BUILD_CONTAINER_VERSION}\" ./scripts/build/ci-build",
"docker push \"grafana/build-container:${BUILD_CONTAINER_VERSION}\"",
],
},
],
)
return [pl]

View File

@@ -5,6 +5,7 @@ pull_secret = "dockerconfigjson"
drone_token = "drone_token"
prerelease_bucket = "prerelease_bucket"
gcp_upload_artifacts_key = "gcp_upload_artifacts_key"
gcp_download_build_container_assets_key = "gcp_download_build_container_assets_key"
azure_sp_app_id = "azure_sp_app_id"
azure_sp_app_pw = "azure_sp_app_pw"
azure_tenant = "azure_tenant"
@@ -38,6 +39,11 @@ def secrets():
"infra/data/ci/grafana/releng/artifacts-uploader-service-account",
"credentials.json",
),
vault_secret(
gcp_download_build_container_assets_key,
"infra/data/ci/grafana/assets-downloader-build-container-service-account",
"credentials.json",
),
vault_secret(
azure_sp_app_id,
"infra/data/ci/datasources/cpp-azure-resourcemanager-credentials",