Skip to content

Commit

Permalink
Merge pull request #16 from mozilla-services/update-deployments-to-ch…
Browse files Browse the repository at this point in the history
…eck-for-monorepos

Update deployments to check for monorepos
  • Loading branch information
hackebrot authored May 29, 2024
2 parents e58fdac + 377657f commit 58f2e1e
Showing 1 changed file with 27 additions and 1 deletion.
28 changes: 27 additions & 1 deletion queries/deployments.sql
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
-- Deployments View: For GitHub `deploy_id` is the ID of the Deployment Status.
WITH
github_repositories AS (
SELECT
github_repository,
COUNT(DISTINCT service) AS count_services,
FROM
`four_keys.services`
GROUP BY
1
),
deploys AS ( -- Cloud Build, GitHub, ArgoCD
SELECT
source,
Expand Down Expand Up @@ -45,11 +54,28 @@ WITH
service_catalog.staging_env,
FROM
deploys
LEFT JOIN
github_repositories
ON
CASE
WHEN deploys.source = "github" THEN deploys.metadata_service = github_repositories.github_repository
ELSE FALSE
END
LEFT JOIN
`four_keys.services` AS service_catalog
ON
CASE
WHEN deploys.source = "github" THEN deploys.metadata_service = service_catalog.github_repository
WHEN
deploys.source = "github"
AND github_repositories.count_services > 1 -- there's more than 1 service in our catalog linked to this GitHub repo.
AND metadata_environment LIKE '%:%' -- the GitHub deployment environment name follows the '%:%' format.
THEN
deploys.metadata_service = service_catalog.github_repository
AND SPLIT(metadata_environment, ':')[OFFSET(0)] = service_catalog.service
WHEN
deploys.source = "github"
THEN
deploys.metadata_service = service_catalog.github_repository
ELSE FALSE
END
),
Expand Down

0 comments on commit 58f2e1e

Please sign in to comment.