Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 9 additions & 4 deletions src/github.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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
Copy link
Member

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"?

Copy link
Member Author

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

Copy link
Member

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? 🤯

Copy link
Member Author

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

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;
Copy link
Member

Choose a reason for hiding this comment

The 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
return !isGitHubHost && !isGitHubEnterpriseCloudHost && !isLocalHost;
const ghUrl = new URL(
process.env['GITHUB_SERVER_URL'] || 'https://github.com'
)
const hostname = ghUrl.hostname.trimEnd().toUpperCase()
const isGitHubHost = hostname === 'GITHUB.COM'
const isGheHost = hostname.endsWith('.GHE.COM')
const isLocalHost = hostname.endsWith('.LOCALHOST')
return !isGitHubHost && !isGheHost && !isLocalHost

Copy link
Member Author

@crazy-max crazy-max Feb 3, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

isGitHubEnterpriseCloudHost is more accurate to not confuse with GitHub Enterprise alone.

Copy link
Member

Choose a reason for hiding this comment

The 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.

Copy link
Member

Choose a reason for hiding this comment

The 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 {
Expand Down
Loading