Skip to content

Commit

Permalink
feat: support bitrise ci
Browse files Browse the repository at this point in the history
  • Loading branch information
jsfez committed Nov 24, 2023
1 parent 0cdfcea commit 079020e
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 6 deletions.
12 changes: 7 additions & 5 deletions packages/core/src/ci-environment/index.ts
Original file line number Diff line number Diff line change
@@ -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";
Expand All @@ -11,13 +12,14 @@ import { debug } from "../debug";
export { CiEnvironment };

const services = [
heroku,
githubActions,
circleci,
travis,
bitrise,
buildkite,
gitlab,
circleci,
git,
githubActions,
gitlab,
heroku,
travis,
];

export const getCiEnvironment = ({
Expand Down
35 changes: 35 additions & 0 deletions packages/core/src/ci-environment/services/bitrise.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import type { Service, Context } from "../types";

const getBranch = ({ env }: Context) => {
const pr =
env.BITRISE_PULL_REQUEST === "false" ? undefined : env.BITRISE_PULL_REQUEST;
const isPr = Boolean(pr);
return isPr ? env.BITRISEIO_GIT_BRANCH_DEST : env.BITRISE_GIT_BRANCH;
};

const getPrNumber = ({ env }: Context) => {
if (env.BITRISE_PULL_REQUEST) {
return Number(env.BITRISE_PULL_REQUEST);
}
return null;
};

const service: Service = {
name: "Bitrise",
detect: ({ env }) => Boolean(env.BITRISE_IO),
config: ({ env }) => {
return {
commit: env.BITRISE_GIT_COMMIT || null,
branch: getBranch({ env }) || 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;
1 change: 0 additions & 1 deletion packages/core/src/ci-environment/services/git.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit 079020e

Please sign in to comment.