diff --git a/gocd/templates/bash/check-github.sh b/gocd/templates/bash/check-github.sh new file mode 100755 index 0000000..e45b771 --- /dev/null +++ b/gocd/templates/bash/check-github.sh @@ -0,0 +1,6 @@ +#!/bin/bash + +checks-githubactions-checkruns \ + getsentry/sentry-orbital \ + "${GO_REVISION_ORBITAL_REPO}" \ + "Build and smoke test" diff --git a/gocd/templates/bash/deploy.sh b/gocd/templates/bash/deploy.sh new file mode 100755 index 0000000..bb92ec7 --- /dev/null +++ b/gocd/templates/bash/deploy.sh @@ -0,0 +1,9 @@ +#!/bin/bash + +eval "$(regions-project-env-vars --region="${SENTRY_REGION}")" + +/devinfra/scripts/get-cluster-credentials \ + && k8s-deploy \ + --label-selector="service=orbital" \ + --image="ghcr.io/getsentry/sentry-orbital:${GO_REVISION_ORBITAL_REPO}" \ + --container-name="orbital" diff --git a/gocd/templates/jsonnetfile.json b/gocd/templates/jsonnetfile.json new file mode 100644 index 0000000..2270013 --- /dev/null +++ b/gocd/templates/jsonnetfile.json @@ -0,0 +1,15 @@ +{ + "version": 1, + "dependencies": [ + { + "source": { + "git": { + "remote": "https://github.com/getsentry/gocd-jsonnet.git", + "subdir": "libs" + } + }, + "version": "v2.19.0" + } + ], + "legacyImports": true +} diff --git a/gocd/templates/jsonnetfile.lock.json b/gocd/templates/jsonnetfile.lock.json new file mode 100644 index 0000000..5b9146f --- /dev/null +++ b/gocd/templates/jsonnetfile.lock.json @@ -0,0 +1,16 @@ +{ + "version": 1, + "dependencies": [ + { + "source": { + "git": { + "remote": "https://github.com/getsentry/gocd-jsonnet.git", + "subdir": "libs" + } + }, + "version": "56cc4d91cbaac4569b37b4911998b48c2f9c2ac4", + "sum": "J0D//go/146qfReWFTTL5xWWCVlkTjqhnALYPH4Z9rE=" + } + ], + "legacyImports": false +} diff --git a/gocd/templates/orbital.jsonnet b/gocd/templates/orbital.jsonnet new file mode 100644 index 0000000..d81f75a --- /dev/null +++ b/gocd/templates/orbital.jsonnet @@ -0,0 +1,32 @@ +local orbital = import './pipelines/orbital.libsonnet'; +local pipedream = import 'github.com/getsentry/gocd-jsonnet/libs/pipedream.libsonnet'; + +local pipedream_config = { + name: 'orbital', + auto_deploy: true, + // US-only + exclude_regions: [ + 's4s', + 's4s2', + 'de', + 'customer-1', + 'customer-2', + 'customer-4', + 'customer-7', + ], + materials: { + orbital_repo: { + git: 'git@github.com:getsentry/sentry-orbital.git', + shallow_clone: false, + branch: 'master', + destination: 'orbital', + }, + }, + rollback: { + material_name: 'orbital_repo', + stage: 'deploy-primary', + elastic_profile_id: 'orbital', + }, +}; + +pipedream.render(pipedream_config, orbital) diff --git a/gocd/templates/pipelines/orbital.libsonnet b/gocd/templates/pipelines/orbital.libsonnet new file mode 100644 index 0000000..678a934 --- /dev/null +++ b/gocd/templates/pipelines/orbital.libsonnet @@ -0,0 +1,49 @@ +local gocdtasks = import 'github.com/getsentry/gocd-jsonnet/libs/gocd-tasks.libsonnet'; + +function(region) { + materials: { + orbital_repo: { + git: 'git@github.com:getsentry/sentry-orbital.git', + shallow_clone: false, + branch: 'master', + destination: 'orbital', + }, + }, + lock_behavior: 'unlockWhenFinished', + stages: [ + { + checks: { + fetch_materials: true, + environment_variables: { + GITHUB_TOKEN: '{{SECRET:[devinfra-github][token]}}', + }, + jobs: { + check: { + timeout: 1200, + elastic_profile_id: 'orbital', + tasks: [ + gocdtasks.script(importstr '../bash/check-github.sh'), + ], + }, + }, + }, + }, + { + 'deploy-primary': { + fetch_materials: true, + environment_variables: { + SENTRY_REGION: region, + }, + jobs: { + deploy: { + timeout: 1200, + elastic_profile_id: 'orbital', + tasks: [ + gocdtasks.script(importstr '../bash/deploy.sh'), + ], + }, + }, + }, + }, + ], +}