@@ -3,6 +3,7 @@ import { isRunningLocalAction } from "../actions-util";
33import * as api from "../api-client" ;
44import { ActionsEnvVars } from "../environment" ;
55import { GITHUB_DOTCOM_URL } from "../github" ;
6+ import { isRepositoryNwoStr , type RepositoryNwoStr } from "../repository" ;
67
78/** The NWO of the standard CodeQL Action repository. */
89export const CODEQL_DEFAULT_ACTION_REPOSITORY = "github/codeql-action" ;
@@ -17,7 +18,7 @@ export const CODEQL_DEFAULT_ACTION_REPOSITORY = "github/codeql-action";
1718 */
1819export function getCodeQLActionRepository (
1920 action : ActionState < [ "ReadOnlyEnv" , "Logger" ] > ,
20- ) : string {
21+ ) : RepositoryNwoStr {
2122 if ( isRunningLocalAction ( action . env ) ) {
2223 // This handles the case where the Action does not come from an Action repository,
2324 // e.g. our integration tests which use the Action code from the current checkout.
@@ -28,11 +29,21 @@ export function getCodeQLActionRepository(
2829 return CODEQL_DEFAULT_ACTION_REPOSITORY ;
2930 }
3031
31- return action . env . getRequired ( ActionsEnvVars . GITHUB_ACTION_REPOSITORY ) ;
32+ const actionRepository = action . env . getRequired (
33+ ActionsEnvVars . GITHUB_ACTION_REPOSITORY ,
34+ ) ;
35+
36+ if ( isRepositoryNwoStr ( actionRepository ) ) {
37+ return actionRepository ;
38+ }
39+
40+ throw new Error (
41+ `The value of '${ ActionsEnvVars . GITHUB_ACTION_REPOSITORY } ' is '${ actionRepository } ', which does not match the expected 'owner/repo' format.` ,
42+ ) ;
3243}
3344
3445/**A download source is a pair of strings. */
35- export type DownloadSource = [ string , string ] ;
46+ export type DownloadSource = [ string , RepositoryNwoStr ] ;
3647
3748/** GitHub.com, and the canonical Action. */
3849export const DEFAULT_DOWNLOAD_SOURCE : DownloadSource = [
@@ -77,7 +88,7 @@ export async function getCodeQLAssetDownloadURL(
7788) : Promise < DownloadURL > {
7889 const codeQLActionRepository = getCodeQLActionRepository ( action ) ;
7990
80- const potentialDownloadSources : Array < [ string , string ] > = [
91+ const potentialDownloadSources : Array < [ string , RepositoryNwoStr ] > = [
8192 // This GitHub instance, and this Action.
8293 [ apiDetails . url , codeQLActionRepository ] ,
8394 // This GitHub instance, and the canonical Action.
0 commit comments