Skip to content

Commit

Permalink
feat(env): update defaults
Browse files Browse the repository at this point in the history
  • Loading branch information
aorinevo committed Oct 3, 2024
1 parent 8ee6498 commit 66bcefe
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
15 changes: 14 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -145,8 +145,21 @@ Shepherd exposes some context to each command via specific environment variables
| `SHEPHERD_GIT_REVISION` | | (`git` and `github` adapters) is the current revision of the repository being operated on. |
| `SHEPHERD_GITHUB_REPO_OWNER` | | (`github` adapter) is the owner of the repository being operated on. For example, if operating on the repository `https://github.com/NerdWalletOSS/shepherd`, this would be `NerdWalletOSS`. |
| `SHEPHERD_GITHUB_REPO_NAME` | | (`github` adapter) is the name of the repository being operated on. For example, if operating on the repository `https://github.com/NerdWalletOSS/shepherd`, this would be `shepherd`. |
| `SHEPHERD_GITHUB_ENTERPRISE_URL` | `api.github.com` | For GitHub Enterprise, export this variable containing the company's GitHub Enterprise url (e.g., `api/github.com/api/v3`). |
| `SHEPHERD_GITHUB_ENTERPRISE_URL` | `api.github.com` | For GitHub Enterprise, export this variable containing the company's GitHub Enterprise url (e.g., `api.github.com/api/v3`). |
| `SHEPHERD_GITHUB_ENTERPRISE_BASE_URL` | `api.github.com` | For GitHub Enterprise, export this variable contraining the company's GitHub Enterprise base url. |
| `SHEPHERD_GITHUB_PROTOCOL` | ssh | (github adapter) is the protocol to use when cloning repos. Can be https or ssh. https is useful when ssh is firewalled. |

**Additional Context**:

When working with GitHub, the API endpoints differ based on whether you are using GitHub's public cloud service, GitHub Enterprise Cloud, or GitHub Enterprise Server (on-premises). Here’s how the endpoints vary:

- GitHub Public (GitHub.com): https://api.github.com/.
- GitHub Enterprise Cloud: https://api.github.com/enterprise/[enterprise-name]
- GitHub Enterprise Server (On-Premises): https://[hostname]/api/v3/

In each case, the API functionality and how you interact with it are largely the same, but the base URL changes based on where your GitHub instance is hosted.

As a result, the value of `SHEPHERD_GITHUB_ENTERPRISE_URL` is a function of the type of GitHub service and used to support git APIs except cloning which is configurable via `SHEPHERD_GITHUB_ENTERPRISE_BASE_URL`. For `SHEPHERD_GITHUB_ENTERPRISE_BASE_URL`, while `github.com` works across GitHub service types, for backwards compatibility, we default to `api.github.com`.

### Usage

Expand Down
3 changes: 2 additions & 1 deletion src/adapters/github.ts
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,8 @@ class GithubAdapter extends GitAdapter {
}

protected getRepositoryUrl(repo: IRepo): string {
const gitHubEnterpriseBaseUrl = process.env.SHEPHERD_GITHUB_ENTERPRISE_BASE_URL ?? 'github.com';
const gitHubEnterpriseBaseUrl =
process.env.SHEPHERD_GITHUB_ENTERPRISE_BASE_URL ?? 'api.github.com';
const githubProtocol = process.env.SHEPHERD_GITHUB_PROTOCOL ?? 'ssh';

if (githubProtocol === 'ssh') {
Expand Down

0 comments on commit 66bcefe

Please sign in to comment.