File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1818 run : |
1919 echo "$GITHUB_CONTEXT"
2020 echo "$GITHUB_CONTEXT" | jq -c '.event.pull_request.commits'
21+ - name : Count test runs for this PR
22+ if : ${{ !cancelled() }}
23+ id : count
24+ uses : actions/github-script@v9
25+ with :
26+ script : |
27+ const pr_number = context.payload.pull_request.number;
28+ const workflow_name = context.workflow;
29+ const event_match = "pull_request";
30+ console.log(pr_number);
31+ console.log(workflow_name);
32+
33+ if (!pr_number) {
34+ console.log("No pull request number found in context.");
35+ core.setOutput("count", 0);
36+ return;
37+ }
38+
39+ const runs = await github.rest.actions.listWorkflowRunsForRepo({
40+ owner: context.repo.owner,
41+ repo: context.repo.repo,
42+ event: event_match,
43+ per_page: 100
44+ });
45+ # console.log(runs);
46+
47+ const filtered = runs.data.workflow_runs.filter(run =>
48+ run.name === workflow_name &&
49+ run.event === event_match &&
50+ run.pull_requests?.some(p => p.number === pr_number)
51+ );
52+ # console.log(filtered);
53+ console.log(filtered.length);
54+
55+ core.setOutput("count", filtered.length);
56+ - name : Dump job context
57+ run : echo "Test run count = ${{ steps.count.outputs.count }}"
2158 - name : Dump job context
2259 env :
2360 JOB_CONTEXT : ${{ toJson(job) }}
You can’t perform that action at this time.
0 commit comments