@@ -95819,6 +95819,76 @@ var __webpack_exports__ = {};
9581995819 });
9582095820 return artifactsResponse.data;
9582195821 }
95822+ async findWorkflowRunByCommit(commitHash, status = 'completed') {
95823+ const { owner, repo } = this.repository;
95824+ try {
95825+ const runsResponse = await this.octokit.rest.actions.listWorkflowRunsForRepo({
95826+ owner,
95827+ repo,
95828+ head_sha: commitHash,
95829+ status,
95830+ per_page: 10
95831+ });
95832+ if (runsResponse.data.workflow_runs && runsResponse.data.workflow_runs.length > 0) {
95833+ const successfulRun = runsResponse.data.workflow_runs.find((run)=>'success' === run.conclusion);
95834+ return successfulRun || runsResponse.data.workflow_runs[0];
95835+ }
95836+ const shortHash = commitHash.substring(0, 10);
95837+ const allRunsResponse = await this.octokit.rest.actions.listWorkflowRunsForRepo({
95838+ owner,
95839+ repo,
95840+ status,
95841+ per_page: 100
95842+ });
95843+ const matchingRun = allRunsResponse.data.workflow_runs?.find((run)=>run.head_sha.startsWith(shortHash) || run.head_sha.startsWith(commitHash));
95844+ return matchingRun || null;
95845+ } catch (error) {
95846+ const apiError = error;
95847+ console.warn(`⚠️ Failed to find workflow run for commit ${commitHash}: ${apiError.message}`);
95848+ return null;
95849+ }
95850+ }
95851+ async findAllWorkflowRunsByCommit(commitHash, status = 'completed') {
95852+ const { owner, repo } = this.repository;
95853+ try {
95854+ const runsResponse = await this.octokit.rest.actions.listWorkflowRunsForRepo({
95855+ owner,
95856+ repo,
95857+ head_sha: commitHash,
95858+ status,
95859+ per_page: 30
95860+ });
95861+ if (runsResponse.data.workflow_runs && runsResponse.data.workflow_runs.length > 0) return runsResponse.data.workflow_runs;
95862+ const shortHash = commitHash.substring(0, 10);
95863+ const allRunsResponse = await this.octokit.rest.actions.listWorkflowRunsForRepo({
95864+ owner,
95865+ repo,
95866+ status,
95867+ per_page: 100
95868+ });
95869+ const matchingRuns = allRunsResponse.data.workflow_runs?.filter((run)=>run.head_sha.startsWith(shortHash) || run.head_sha.startsWith(commitHash)) || [];
95870+ return matchingRuns;
95871+ } catch (error) {
95872+ const apiError = error;
95873+ console.warn(`⚠️ Failed to find workflow runs for commit ${commitHash}: ${apiError.message}`);
95874+ return [];
95875+ }
95876+ }
95877+ async listArtifactsForWorkflowRun(runId) {
95878+ const { owner, repo } = this.repository;
95879+ try {
95880+ const artifactsResponse = await this.octokit.rest.actions.listWorkflowRunArtifacts({
95881+ owner,
95882+ repo,
95883+ run_id: runId
95884+ });
95885+ return artifactsResponse.data;
95886+ } catch (error) {
95887+ const apiError = error;
95888+ console.warn(`⚠️ Failed to list artifacts for workflow run ${runId}: ${apiError.message}`);
95889+ throw error;
95890+ }
95891+ }
9582295892 async findArtifactByNamePattern(pattern) {
9582395893 const artifacts = await this.listArtifacts();
9582495894 console.log(`Looking for artifacts matching pattern: ${pattern}`);
@@ -95981,30 +96051,62 @@ var __webpack_exports__ = {};
9598196051 console.log(`📋 Searching for artifact with path hash and commit hash: ${expectedArtifactName}`);
9598296052 console.log(` Path hash: ${pathHash}`);
9598396053 console.log(` File path: ${relativePath}`);
95984- const artifacts = await githubService.listArtifacts();
95985- const artifact = artifacts.artifacts.find((a)=>a.name === expectedArtifactName);
96054+ console.log(`🔍 Looking for workflow runs with commit hash: ${commitHash}`);
96055+ const workflowRuns = await githubService.findAllWorkflowRunsByCommit(commitHash);
96056+ let artifact = null;
96057+ let artifacts = null;
96058+ if (workflowRuns && workflowRuns.length > 0) {
96059+ console.log(`✅ Found ${workflowRuns.length} workflow run(s) for commit ${commitHash}`);
96060+ for (const workflowRun of workflowRuns){
96061+ console.log(`\n🔍 Checking workflow run: ${workflowRun.id} (${workflowRun.name || 'unnamed'})`);
96062+ console.log(` Status: ${workflowRun.status}, Conclusion: ${workflowRun.conclusion}`);
96063+ try {
96064+ const runArtifacts = await githubService.listArtifactsForWorkflowRun(workflowRun.id);
96065+ const foundArtifact = runArtifacts.artifacts?.find((a)=>a.name === expectedArtifactName);
96066+ if (foundArtifact) {
96067+ artifact = foundArtifact;
96068+ artifacts = runArtifacts;
96069+ console.log(`✅ Found artifact in workflow run ${workflowRun.id}: ${artifact.name} (ID: ${artifact.id})`);
96070+ break;
96071+ }
96072+ {
96073+ const artifactNames = runArtifacts.artifacts?.map((a)=>a.name).join(', ') || 'none';
96074+ console.log(` ⚠️ Artifact not found. Available artifacts: ${artifactNames}`);
96075+ }
96076+ } catch (runArtifactsError) {
96077+ console.warn(` ⚠️ Failed to get artifacts from workflow run ${workflowRun.id}: ${runArtifactsError}`);
96078+ continue;
96079+ }
96080+ }
96081+ if (!artifact) {
96082+ console.log(`\n⚠️ Artifact not found in any of the ${workflowRuns.length} workflow runs`);
96083+ console.log(`🔄 Falling back to listing all repository artifacts...`);
96084+ }
96085+ } else {
96086+ console.log(`⚠️ No workflow runs found for commit ${commitHash}`);
96087+ console.log(`🔄 Falling back to listing all repository artifacts...`);
96088+ }
96089+ if (!artifact) {
96090+ artifacts = await githubService.listArtifacts();
96091+ artifact = artifacts.artifacts.find((a)=>a.name === expectedArtifactName);
96092+ }
9598696093 if (!artifact) {
9598796094 console.log(`❌ No artifact found matching: ${expectedArtifactName}`);
95988- console.log(` Available artifacts: ${artifacts.artifacts.map((a)=>a.name).join(', ')}`);
96095+ if (artifacts?.artifacts) console.log(` Available artifacts: ${artifacts.artifacts.map((a)=>a.name).join(', ')}`);
9598996096 console.log(`💡 This might mean:`);
9599096097 console.log(" - The target branch hasn't been built yet");
9599196098 console.log(" - The artifact name pattern doesn't match");
9599296099 console.log(" - The artifact has expired (GitHub artifacts expire after 90 days)");
9599396100 throw new Error(`No artifact found matching: ${expectedArtifactName}`);
9599496101 }
9599596102 console.log(`✅ Found exact match: ${artifact.name} (ID: ${artifact.id})`);
95996- try {
95997- const artifacts = await githubService.listArtifacts();
95998- const artifactDetails = artifacts.artifacts.find((a)=>a.id === artifact.id);
95999- if (artifactDetails) {
96000- console.log(`📊 Artifact details:`);
96001- console.log(` - Created: ${artifactDetails.created_at}`);
96002- console.log(` - Expired: ${artifactDetails.expired_at || 'Not expired'}`);
96003- console.log(` - Size: ${artifactDetails.size_in_bytes} bytes`);
96004- if (artifactDetails.expired_at) console.log(`⚠️ Warning: This artifact has expired and may not be downloadable`);
96005- }
96006- } catch (detailError) {
96007- console.warn(`⚠️ Could not get artifact details: ${detailError || 'Unknown error'}`);
96103+ const artifactDetails = artifact;
96104+ if (artifactDetails) {
96105+ console.log(`📊 Artifact details:`);
96106+ console.log(` - Created: ${artifactDetails.created_at}`);
96107+ console.log(` - Expired: ${artifactDetails.expired_at || 'Not expired'}`);
96108+ console.log(` - Size: ${artifactDetails.size_in_bytes} bytes`);
96109+ if (artifactDetails.expired_at) console.log(`⚠️ Warning: This artifact has expired and may not be downloadable`);
9600896110 }
9600996111 console.log(`📥 Downloading artifact...`);
9601096112 try {
0 commit comments