fix(ci): improve workflow run condition and artifact collection

Fixes workflow trigger condition by explicitly checking for workflow_run event type to prevent unintended executions.

Improves artifact collection reliability by switching to the correct API method and increasing page size to capture more artifacts from multiple builds.

Removes redundant artifact fetching logic that was duplicating collection efforts.
This commit is contained in:
Uruk
2025-09-29 23:55:36 +02:00
parent 1ff09a2d34
commit 0d1aeaf8aa

View File

@@ -16,7 +16,7 @@ on:
jobs: jobs:
comment-artifacts: comment-artifacts:
if: github.event_name == 'workflow_dispatch' || github.event.workflow_run.event == 'pull_request' if: github.event_name == 'workflow_dispatch' || (github.event_name == 'workflow_run' && github.event.workflow_run.event == 'pull_request')
runs-on: ubuntu-latest runs-on: ubuntu-latest
permissions: permissions:
contents: read contents: read
@@ -63,11 +63,11 @@ jobs:
console.log(`Processing PR #${pr.number} for commit ${pr.head.sha.substring(0, 7)}`); console.log(`Processing PR #${pr.number} for commit ${pr.head.sha.substring(0, 7)}`);
// Get all recent workflow runs for this PR to collect artifacts from multiple builds // Get all recent workflow runs for this PR to collect artifacts from multiple builds
const { data: workflowRuns } = await github.rest.actions.listWorkflowRuns({ const { data: workflowRuns } = await github.rest.actions.listWorkflowRunsForRepo({
owner: context.repo.owner, owner: context.repo.owner,
repo: context.repo.repo, repo: context.repo.repo,
head_sha: pr.head.sha, head_sha: pr.head.sha,
per_page: 10 per_page: 20
}); });
// Filter for build workflows only // Filter for build workflows only
@@ -106,13 +106,6 @@ jobs:
console.log(`Collected ${allArtifacts.length} total artifacts from all builds`); console.log(`Collected ${allArtifacts.length} total artifacts from all builds`);
// Get artifacts from current run if needed
const { data: artifacts } = await github.rest.actions.listWorkflowRunArtifacts({
owner: context.repo.owner,
repo: context.repo.repo,
run_id: runId
});
// Sort and categorize all collected artifacts // Sort and categorize all collected artifacts
const androidArtifacts = allArtifacts const androidArtifacts = allArtifacts
.filter(a => a.name.includes('android')) .filter(a => a.name.includes('android'))