ci: Improve nightly build status check in CI workflow (#6845)
This commit is contained in:
parent
c57ed6f464
commit
a94654d584
1 changed files with 12 additions and 6 deletions
18
.github/workflows/ci.yml
vendored
18
.github/workflows/ci.yml
vendored
|
|
@ -57,23 +57,29 @@ jobs:
|
||||||
with:
|
with:
|
||||||
script: |
|
script: |
|
||||||
const workflow_name = 'nightly_build.yml';
|
const workflow_name = 'nightly_build.yml';
|
||||||
|
const today = new Date();
|
||||||
|
today.setHours(0, 0, 0, 0); // Set to beginning of day
|
||||||
|
|
||||||
const { data: runs } = await github.rest.actions.listWorkflowRuns({
|
const { data: runs } = await github.rest.actions.listWorkflowRuns({
|
||||||
owner: context.repo.owner,
|
owner: context.repo.owner,
|
||||||
repo: context.repo.repo,
|
repo: context.repo.repo,
|
||||||
workflow_id: workflow_name,
|
workflow_id: workflow_name,
|
||||||
per_page: 1,
|
created: `>=${today.toISOString()}`,
|
||||||
|
per_page: 100, // Get more runs to check
|
||||||
status: 'completed'
|
status: 'completed'
|
||||||
});
|
});
|
||||||
|
|
||||||
if (runs.workflow_runs.length === 0) {
|
if (runs.workflow_runs.length === 0) {
|
||||||
console.log('No completed workflow runs found');
|
console.log('No completed workflow runs found today');
|
||||||
return core.setOutput('success', 'true');
|
return core.setOutput('success', 'true');
|
||||||
}
|
}
|
||||||
|
|
||||||
const lastRun = runs.workflow_runs[0];
|
// Check if any runs today were successful
|
||||||
const success = lastRun.conclusion === 'success';
|
const successfulTodayRuns = runs.workflow_runs.filter(run => run.conclusion === 'success');
|
||||||
console.log(`Last nightly build status: ${lastRun.conclusion}`);
|
const hasSuccessfulRunToday = successfulTodayRuns.length > 0;
|
||||||
core.setOutput('success', success.toString());
|
|
||||||
|
console.log(`Found ${runs.workflow_runs.length} completed runs today, ${successfulTodayRuns.length} successful`);
|
||||||
|
core.setOutput('success', hasSuccessfulRunToday.toString());
|
||||||
|
|
||||||
set-ci-condition:
|
set-ci-condition:
|
||||||
needs: check-nightly-status
|
needs: check-nightly-status
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue