@@ -10,6 +10,8 @@ import { RemoteQuery } from './remote-query';
1010import { RemoteQueryFailureIndexItem , RemoteQueryResultIndex , RemoteQuerySuccessIndexItem } from './remote-query-result-index' ;
1111import { getErrorMessage } from '../pure/helpers-pure' ;
1212
13+ export const RESULT_INDEX_ARTIFACT_NAME = 'result-index' ;
14+
1315interface ApiSuccessIndexItem {
1416 nwo : string ;
1517 id : string ;
@@ -44,7 +46,7 @@ export async function getRemoteQueryIndex(
4446 const artifactsUrlPath = `/repos/${ owner } /${ repoName } /actions/artifacts` ;
4547
4648 const artifactList = await listWorkflowRunArtifacts ( credentials , owner , repoName , workflowRunId ) ;
47- const resultIndexArtifactId = tryGetArtifactIDfromName ( 'result-index' , artifactList ) ;
49+ const resultIndexArtifactId = tryGetArtifactIDfromName ( RESULT_INDEX_ARTIFACT_NAME , artifactList ) ;
4850 if ( ! resultIndexArtifactId ) {
4951 return undefined ;
5052 }
@@ -116,6 +118,27 @@ export async function downloadArtifactFromLink(
116118 return path . join ( extractedPath , downloadLink . innerFilePath || '' ) ;
117119}
118120
121+ /**
122+ * Checks whether a specific artifact is present in the list of artifacts of a workflow run.
123+ * @param credentials Credentials for authenticating to the GitHub API.
124+ * @param owner
125+ * @param repo
126+ * @param workflowRunId The ID of the workflow run to get the artifact for.
127+ * @param artifactName The artifact name, as a string.
128+ * @returns A boolean indicating if the artifact is available.
129+ */
130+ export async function isArtifactAvailable (
131+ credentials : Credentials ,
132+ owner : string ,
133+ repo : string ,
134+ workflowRunId : number ,
135+ artifactName : string ,
136+ ) : Promise < boolean > {
137+ const artifactList = await listWorkflowRunArtifacts ( credentials , owner , repo , workflowRunId ) ;
138+
139+ return tryGetArtifactIDfromName ( artifactName , artifactList ) !== undefined ;
140+ }
141+
119142/**
120143 * Downloads the result index artifact and extracts the result index items.
121144 * @param credentials Credentials for authenticating to the GitHub API.
0 commit comments