diff --git a/dashboard/src/modules/config-store/store-github-builds.server.ts b/dashboard/src/modules/config-store/store-github-builds.server.ts index 1b591304da..807fd1d41d 100644 --- a/dashboard/src/modules/config-store/store-github-builds.server.ts +++ b/dashboard/src/modules/config-store/store-github-builds.server.ts @@ -7,6 +7,7 @@ import type { StoreRefused } from "#/modules/config-store/store.contract"; import { pinStoreSources } from "#/modules/config-store/store-deployment.server"; import { organizationAccess } from "#/modules/github/github-access"; import { cancelGithubRun, checkGithubBuildWorkflow, dispatchGithubBuildWorkflow, githubRunCompleted } from "#/modules/github/github-build.server"; +import { githubBuildId } from "#/modules/github/github-build-workflow"; import { verifyGithubOidcToken } from "#/modules/github/github-oidc.server"; import { installationRefusal } from "#/modules/github/github-token.server"; import { sendInngestEvent } from "#/modules/inngest/client"; @@ -86,7 +87,7 @@ export const planStoreGithubBuilds = Effect.fn("StoreGithub.plan")(function* (da const walk = servers ? source.builders : source.builders.filter((builder) => builder !== "servers"); if (walk[0] !== "github") return []; return [{ - build: `${data.deploymentId}.${source.service}`, + build: githubBuildId(data.deploymentId, source.service), service: source.service, repository: source.repository, repositoryId: source.repository_id, diff --git a/dashboard/src/modules/github/github-build-workflow.ts b/dashboard/src/modules/github/github-build-workflow.ts index b9200308be..9294816edc 100644 --- a/dashboard/src/modules/github/github-build-workflow.ts +++ b/dashboard/src/modules/github/github-build-workflow.ts @@ -25,6 +25,10 @@ jobs: cloud: \${{ inputs.cloud }} `; +export function githubBuildId(deploymentId: string, service: string) { + return `${deploymentId}.${service}`; +} + /** * Readiness of one repository for GitHub builds, as Cloud last checked it. * `waiting` (Add workflow opened, commit not seen yet) is only known to the browser that opened it. diff --git a/dashboard/src/modules/github/github-build.test.ts b/dashboard/src/modules/github/github-build.test.ts index a62232a425..1b685fabd5 100644 --- a/dashboard/src/modules/github/github-build.test.ts +++ b/dashboard/src/modules/github/github-build.test.ts @@ -2,7 +2,7 @@ import { Effect, Schema } from "effect"; import { describe, expect, it } from "vitest"; import { organizationAccess } from "./github-access"; import { checkGithubBuildWorkflow } from "./github-build.server"; -import { GITHUB_BUILD_WORKFLOW, githubBuildWorkflowUrl } from "./github-build-workflow"; +import { GITHUB_BUILD_WORKFLOW, githubBuildId, githubBuildWorkflowUrl } from "./github-build-workflow"; import { GithubApi, GithubObservationError, type GithubObservationErrorCode } from "./github-observation.api"; describe("GitHub build workflow", () => { @@ -13,6 +13,14 @@ describe("GitHub build workflow", () => { } }); + it("dispatches build ids that getployz/build@v1 accepts", () => { + const accepted = /^[A-Za-z0-9_-][A-Za-z0-9._-]{0,127}$/; + const deployment = "36755d9a-dc30-4385-a9bd-86ae1a85e44b"; + for (const service of ["a", "ployz-soak-node", "s".repeat(63)]) { + expect(githubBuildId(deployment, service)).toMatch(accepted); + } + }); + it("opens GitHub's new-file page on the default branch with the workflow filled in", () => { const url = new URL(githubBuildWorkflowUrl({ web: "http://127.0.0.1:4555", fullName: "acme/api", defaultBranch: "release/v2" })); expect(url.origin + url.pathname).toBe("http://127.0.0.1:4555/acme/api/new/release/v2");