From 98c83595f4710e865cbeccdac3686fcf85b53908 Mon Sep 17 00:00:00 2001 From: Jeremy SFEZ Date: Fri, 24 Nov 2023 09:44:34 +0100 Subject: [PATCH] feat(ci): support Bitrise CI (#89) --- packages/core/src/ci-environment/index.ts | 4 +++ .../src/ci-environment/services/bitrise.ts | 25 +++++++++++++++++++ .../core/src/ci-environment/services/git.ts | 1 - 3 files changed, 29 insertions(+), 1 deletion(-) create mode 100644 packages/core/src/ci-environment/services/bitrise.ts diff --git a/packages/core/src/ci-environment/index.ts b/packages/core/src/ci-environment/index.ts index 75a29601..749b9d68 100644 --- a/packages/core/src/ci-environment/index.ts +++ b/packages/core/src/ci-environment/index.ts @@ -1,3 +1,4 @@ +import bitrise from "./services/bitrise"; import buildkite from "./services/buildkite"; import heroku from "./services/heroku"; import githubActions from "./services/github-actions"; @@ -10,6 +11,8 @@ import { debug } from "../debug"; export { CiEnvironment }; +// List of services ordered by usage +// "git" must be the last one const services = [ heroku, githubActions, @@ -17,6 +20,7 @@ const services = [ travis, buildkite, gitlab, + bitrise, git, ]; diff --git a/packages/core/src/ci-environment/services/bitrise.ts b/packages/core/src/ci-environment/services/bitrise.ts new file mode 100644 index 00000000..0022a313 --- /dev/null +++ b/packages/core/src/ci-environment/services/bitrise.ts @@ -0,0 +1,25 @@ +import type { Service, Context } from "../types"; + +const getPrNumber = ({ env }: Context) => { + return env.BITRISE_PULL_REQUEST ? Number(env.BITRISE_PULL_REQUEST) : null; +}; + +const service: Service = { + name: "Bitrise", + detect: ({ env }) => Boolean(env.BITRISE_IO), + config: ({ env }) => { + return { + commit: env.BITRISE_GIT_COMMIT || null, + branch: env.BITRISE_GIT_BRANCH || null, + owner: env.BITRISEIO_GIT_REPOSITORY_OWNER || null, + repository: env.BITRISEIO_GIT_REPOSITORY_SLUG || null, + jobId: null, + runId: null, + prNumber: getPrNumber({ env }), + prHeadCommit: null, + nonce: env.BITRISEIO_PIPELINE_ID || null, + }; + }, +}; + +export default service; diff --git a/packages/core/src/ci-environment/services/git.ts b/packages/core/src/ci-environment/services/git.ts index 61262a0c..ce7103fa 100644 --- a/packages/core/src/ci-environment/services/git.ts +++ b/packages/core/src/ci-environment/services/git.ts @@ -6,7 +6,6 @@ const service: Service = { detect: () => checkIsGitRepository(), config: () => { return { - // Buildkite doesn't work well so we fallback to git to ensure we have commit and branch commit: head() || null, branch: branch() || null, owner: null,