Comparing version 11.0.0 to 11.1.0
@@ -36,1 +36,30 @@ import { execaSync } from "execa"; | ||
} | ||
// Match slug on SSH URLs (ex: `USER@HOST:PORT/ORG/REPO.git`) | ||
const GIT_SSH_URL_SLUG_PATTERN = /^(?:.*)@(?:.*):(?:\d+\/)?(.*)\.git$/; | ||
// Match slug on HTTP(S) URLs `https://github.com/semantic-release/env-ci.git` | ||
const GIT_PATHNAME_SLUG_PATTERN = /^\/(.*)\.git$/; | ||
/** | ||
* Extract repository slug(owner/repo) from a repository URL | ||
* | ||
* @param {String} repositoryURL | ||
* @returns {String | undefined} | ||
*/ | ||
export function getSlugFromGitURL(repositoryURL) { | ||
if (!repositoryURL) { | ||
return undefined; | ||
} | ||
if (repositoryURL.match(GIT_SSH_URL_SLUG_PATTERN)) { | ||
return repositoryURL.replace(GIT_SSH_URL_SLUG_PATTERN, "$1"); | ||
} | ||
try { | ||
const url = new URL(repositoryURL); | ||
return url.pathname.replace(GIT_PATHNAME_SLUG_PATTERN, "$1"); | ||
} catch { | ||
return undefined; | ||
} | ||
} |
{ | ||
"name": "env-ci", | ||
"description": "Get environment variables exposed by CI services", | ||
"version": "11.0.0", | ||
"version": "11.1.0", | ||
"author": "Pierre Vanduynslager (https://github.com/pvdlg)", | ||
@@ -13,6 +13,6 @@ "type": "module", | ||
"devDependencies": { | ||
"ava": "6.0.1", | ||
"c8": "8.0.1", | ||
"ava": "6.1.3", | ||
"c8": "10.1.2", | ||
"file-url": "4.0.0", | ||
"prettier": "3.1.1", | ||
"prettier": "3.3.3", | ||
"tempy": "3.1.0" | ||
@@ -77,5 +77,5 @@ }, | ||
"extends": [ | ||
"github>semantic-release/.github" | ||
"github>semantic-release/.github:renovate-config" | ||
] | ||
} | ||
} |
@@ -91,3 +91,3 @@ # env-ci | ||
| [Bitrise](https://devcenter.bitrise.io/builds/available-environment-variables/#exposed-by-bitriseio) | `bitrise` | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :x: | :x: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :x: | | ||
| [Buddy](https://buddy.works/knowledge/deployments/how-use-environment-variables#default-environment-variables) | `buddy` | :white_check_mark: | [:warning:](#buddy) | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :x: | :x: | :white_check_mark: | :white_check_mark: | :x: | :white_check_mark: | :x: | | ||
| [Buddy](https://buddy.works/knowledge/deployments/how-use-environment-variables#default-environment-variables) | `buddy` | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :x: | :x: | :white_check_mark: | :white_check_mark: | :x: | :white_check_mark: | :x: | | ||
| [Buildkite](https://buildkite.com/docs/builds/environment-variables) | `buildkite` | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :x: | :x: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | | ||
@@ -168,13 +168,2 @@ | [CircleCI](https://circleci.com/docs/2.0/env-vars/#built-in-environment-variables) | `circleci` | :white_check_mark: | [:warning:](#circleci) | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :x: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :x: | | ||
### Buddy | ||
For builds triggered when [a Pull Request is opened/updated](https://buddy.works/knowledge/deployments/pull-requests), | ||
Buddy doesn't provide an environment variable indicating the branch from which the Pull Request originated nor the | ||
target branch. It also build from a branch named `pull/<PR number>` so the target branch cannot be determined with | ||
a `git` command. | ||
Therefore, in the case of Pull Request builds, `env-ci` will not be able to determine the `branch` and `prBranch` | ||
properties. | ||
See [feature request](https://forum.buddy.works/t/determine-pull-request-branch-with-environment-variable/911). | ||
### CircleCI | ||
@@ -181,0 +170,0 @@ |
@@ -20,3 +20,5 @@ // https://buddy.works/knowledge/deployments/how-use-environment-variables#default-environment-variables | ||
buildUrl: env.BUDDY_EXECUTION_URL, | ||
branch: isPr ? undefined : env.BUDDY_EXECUTION_BRANCH, | ||
branch: isPr | ||
? env.BUDDY_EXECUTION_PULL_REQUEST_HEAD_BRANCH | ||
: env.BUDDY_EXECUTION_BRANCH, | ||
pr, | ||
@@ -23,0 +25,0 @@ isPr, |
// https://buildkite.com/docs/builds/environment-variables | ||
import { getSlugFromGitURL } from "../lib/git.js"; | ||
@@ -24,3 +25,3 @@ export default { | ||
: env.BUILDKITE_BRANCH, | ||
slug: `${env.BUILDKITE_ORGANIZATION_SLUG}/${env.BUILDKITE_PROJECT_SLUG}`, | ||
slug: getSlugFromGitURL(env.BUILDKITE_REPO), | ||
pr, | ||
@@ -27,0 +28,0 @@ isPr, |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
53402
928
220