-
Notifications
You must be signed in to change notification settings - Fork 42
github: vendor isGhes() func from @actions/artifact module #974
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -22,7 +22,6 @@ import os from 'os'; | |||||||||||||||||||||||
| import path from 'path'; | ||||||||||||||||||||||||
| import {CreateArtifactRequest, FinalizeArtifactRequest, StringValue} from '@actions/artifact/lib/generated'; | ||||||||||||||||||||||||
| import {internalArtifactTwirpClient} from '@actions/artifact/lib/internal/shared/artifact-twirp-client'; | ||||||||||||||||||||||||
| import {isGhes} from '@actions/artifact/lib/internal/shared/config'; | ||||||||||||||||||||||||
| import {getBackendIdsFromToken} from '@actions/artifact/lib/internal/shared/util'; | ||||||||||||||||||||||||
| import {getExpiration} from '@actions/artifact/lib/internal/upload/retention'; | ||||||||||||||||||||||||
| import {InvalidResponseError, NetworkError} from '@actions/artifact'; | ||||||||||||||||||||||||
|
|
@@ -96,10 +95,16 @@ export class GitHub { | |||||||||||||||||||||||
| return process.env.GITHUB_API_URL || 'https://api.github.com'; | ||||||||||||||||||||||||
| } | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| // Can't use the isGhes() func from @actions/artifact due to @actions/artifact/lib/internal/shared/config | ||||||||||||||||||||||||
| // being internal since ESM-only packages do not support internal exports. | ||||||||||||||||||||||||
| // https://github.com/actions/toolkit/blob/8351a5d84d862813d1bb8bdeef87b215f8a946f9/packages/artifact/src/internal/shared/config.ts#L27 | ||||||||||||||||||||||||
| static get isGHES(): boolean { | ||||||||||||||||||||||||
| // FIXME: we are using the function from GitHub artifact module but should | ||||||||||||||||||||||||
| // be within core module when available. | ||||||||||||||||||||||||
| return isGhes(); | ||||||||||||||||||||||||
| const ghURL = new URL(GitHub.serverURL); | ||||||||||||||||||||||||
| const hostname = ghURL.hostname.trimEnd().toUpperCase(); | ||||||||||||||||||||||||
| const isGitHubHost = hostname === 'GITHUB.COM'; | ||||||||||||||||||||||||
| const isGitHubEnterpriseCloudHost = hostname.endsWith('.GHE.COM'); | ||||||||||||||||||||||||
| const isLocalHost = hostname.endsWith('.LOCALHOST'); | ||||||||||||||||||||||||
| return !isGitHubHost && !isGitHubEnterpriseCloudHost && !isLocalHost; | ||||||||||||||||||||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Any reason not to copy the code verbatim (same names etc)?
Suggested change
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This one would still be nice though (if it works); it helps visually comparing and make sure we didn't diverge / missed changes from upstream.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Doh! Race condition in our comments 😂 Yeah, perhaps just renaming the var could work; mostly trying to keep them as close as possible 😅 |
||||||||||||||||||||||||
| } | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| static get repository(): string { | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would it make sense to use a tag instead of a commit as reference? That way it may be easier in future to consider "this was forked a few versions ago, let's look if there are any changes since vX.Y.Z"?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
They don't use tags anymore unfortunately: https://github.com/actions/toolkit/tags
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's ... weird!! They try to move everyone to immutable and their own stuff doesn't even use tags? 🤯
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes very weird, it makes it hard to link npm module version with actual git ref