@@ -202,32 +202,43 @@ func init() {
202202
203203func fetchArtifactLink (githubToken , githubRepo string , githubRunID int64 , artifactName string ) (string , error ) {
204204 ctx := context .Background ()
205- ts := oauth2 .StaticTokenSource (
206- & oauth2.Token {AccessToken : githubToken },
207- )
205+ ts := oauth2 .StaticTokenSource (& oauth2.Token {AccessToken : githubToken })
208206 tc := oauth2 .NewClient (ctx , ts )
209207 client := github .NewClient (tc )
210208
211- // Split the repository into owner and repo
209+ // Split owner/ repo
212210 repoParts := strings .SplitN (githubRepo , "/" , 2 )
213211 if len (repoParts ) != 2 {
214212 return "" , fmt .Errorf ("invalid format for --github-repository, expected owner/repo" )
215213 }
216214 owner , repo := repoParts [0 ], repoParts [1 ]
217215
218- // List artifacts for the workflow run
219- opts := & github.ListOptions {PerPage : 500 }
220- artifacts , _ , err := client .Actions .ListWorkflowRunArtifacts (ctx , owner , repo , githubRunID , opts )
221- if err != nil {
222- return "" , fmt .Errorf ("error listing artifacts: %w" , err )
216+ opts := & github.ListOptions {PerPage : 100 } // The max GitHub allows is 100 per page
217+ var allArtifacts []* github.Artifact
218+
219+ // Paginate through all artifacts
220+ for {
221+ artifacts , resp , err := client .Actions .ListWorkflowRunArtifacts (ctx , owner , repo , githubRunID , opts )
222+ if err != nil {
223+ return "" , fmt .Errorf ("error listing artifacts: %w" , err )
224+ }
225+
226+ allArtifacts = append (allArtifacts , artifacts .Artifacts ... )
227+
228+ if resp .NextPage == 0 {
229+ // No more pages
230+ break
231+ }
232+ // Move to the next page
233+ opts .Page = resp .NextPage
223234 }
224235
225- // Find the artifact
226- for _ , artifact := range artifacts . Artifacts {
236+ // Find the artifact we want
237+ for _ , artifact := range allArtifacts {
227238 if artifact .GetName () == artifactName {
228- // Construct the artifact URL using the artifact ID
229239 artifactID := artifact .GetID ()
230- artifactURL := fmt .Sprintf ("https://github.com/%s/%s/actions/runs/%d/artifacts/%d" , owner , repo , githubRunID , artifactID )
240+ artifactURL := fmt .Sprintf ("https://github.com/%s/%s/actions/runs/%d/artifacts/%d" ,
241+ owner , repo , githubRunID , artifactID )
231242 return artifactURL , nil
232243 }
233244 }
0 commit comments