@teambit/ci 1.0.632 → 1.0.633

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/ci.docs.mdx CHANGED
@@ -467,6 +467,14 @@ For GitHub, the command reads **`BIT_GITHUB_TOKEN` before `GITHUB_TOKEN`**. GitH
467
467
  `GITHUB_TOKEN` on every job, so an override needs the higher priority. The command reads the repository from
468
468
  `GITHUB_REPOSITORY`. If that variable is absent, the command reads the `origin` remote.
469
469
 
470
+ On GitHub Enterprise Server, the command also claims an `origin` remote on the host that `GITHUB_SERVER_URL`
471
+ names, and sends the API requests for that host to `GITHUB_API_URL`. GitHub Actions sets both variables on
472
+ every job. Outside Actions, set `GITHUB_SERVER_URL` (for example `https://ghe.example.com`); without
473
+ `GITHUB_API_URL` the API defaults to `https://ghe.example.com/api/v3`. A `GITHUB_API_URL` must be on the server
474
+ host or on `api.<server host>` (GHE.com data residency), and must be `https` when the server is; any other
475
+ value is refused with a warning and the GitHub provider stays unconfigured, so the enterprise token is never
476
+ sent elsewhere. A github.com remote on such a runner still uses `https://api.github.com`.
477
+
470
478
  ---
471
479
 
472
480
  ## Configuration
package/dist/ci.docs.mdx CHANGED
@@ -467,6 +467,14 @@ For GitHub, the command reads **`BIT_GITHUB_TOKEN` before `GITHUB_TOKEN`**. GitH
467
467
  `GITHUB_TOKEN` on every job, so an override needs the higher priority. The command reads the repository from
468
468
  `GITHUB_REPOSITORY`. If that variable is absent, the command reads the `origin` remote.
469
469
 
470
+ On GitHub Enterprise Server, the command also claims an `origin` remote on the host that `GITHUB_SERVER_URL`
471
+ names, and sends the API requests for that host to `GITHUB_API_URL`. GitHub Actions sets both variables on
472
+ every job. Outside Actions, set `GITHUB_SERVER_URL` (for example `https://ghe.example.com`); without
473
+ `GITHUB_API_URL` the API defaults to `https://ghe.example.com/api/v3`. A `GITHUB_API_URL` must be on the server
474
+ host or on `api.<server host>` (GHE.com data residency), and must be `https` when the server is; any other
475
+ value is refused with a warning and the GitHub provider stays unconfigured, so the enterprise token is never
476
+ sent elsewhere. A github.com remote on such a runner still uses `https://api.github.com`.
477
+
470
478
  ---
471
479
 
472
480
  ## Configuration
@@ -376,10 +376,14 @@ class CiMain {
376
376
  if (!pullRequestUrl) return undefined;
377
377
  try {
378
378
  const {
379
+ hostname,
379
380
  pathname
380
381
  } = new URL(pullRequestUrl);
381
382
  const [, owner, repo, pullSegment, pullNumber] = pathname.split('/');
382
383
  if (!owner || !repo || pullSegment !== 'pull' || !pullNumber) return undefined;
384
+ // an enterprise API the environment can't vouch for gets no token, and no request
385
+ const api = (0, _githubClient().gitHubApiUrl)(hostname);
386
+ if ('error' in api) return undefined;
383
387
  const headers = {
384
388
  Accept: 'application/vnd.github+json',
385
389
  'X-GitHub-Api-Version': '2022-11-28'
@@ -388,7 +392,7 @@ class CiMain {
388
392
  const controller = new AbortController();
389
393
  const timeout = setTimeout(() => controller.abort(), 5_000);
390
394
  try {
391
- const response = await fetch(`https://api.github.com/repos/${owner}/${repo}/pulls/${pullNumber}`, {
395
+ const response = await fetch(`${api.url}/repos/${owner}/${repo}/pulls/${pullNumber}`, {
392
396
  headers,
393
397
  signal: controller.signal
394
398
  });