-
-
Notifications
You must be signed in to change notification settings - Fork 0
76 lines (64 loc) · 2.77 KB
/
status-check.yml
File metadata and controls
76 lines (64 loc) · 2.77 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
name: "Status Check: Validate All Workflows"
on:
schedule:
- cron: '0 9 * * *' # Daily at 9am UTC
workflow_dispatch: # Allow manual triggering
jobs:
check-status:
runs-on: ubuntu-latest
steps:
- name: Check workflow statuses
uses: actions/github-script@v9
with:
script: |
const workflows = [
'coverage.yml',
'daily-erb-lint.yml',
'daily-standardrb.yml',
'security-scan.yml',
'test-ruby.yml',
'weekly-updates.yml'
];
const getWorkflowRun = async (workflow) => {
const { data } = await github.rest.actions.listWorkflowRuns({
owner: context.repo.owner,
repo: context.repo.repo,
workflow_id: workflow,
per_page: 1
});
return data.workflow_runs[0];
};
const statusEmoji = (status, conclusion) => {
if (status === 'in_progress' || status === 'queued') return '🚴';
return {
'success': '💚',
'failure': '💀',
'cancelled': '⚠️'
}[conclusion] || '❓';
};
const timeAgo = (date) => {
const seconds = Math.floor((new Date() - date) / 1000);
const minutes = Math.floor(seconds / 60);
const hours = Math.floor(minutes / 60);
const days = Math.floor(hours / 24);
if (days > 0) return `${days} day${days === 1 ? '' : 's'} ago`;
if (hours > 0) return `${hours} hour${hours === 1 ? '' : 's'} ago`;
if (minutes > 0) return `${minutes} minute${minutes === 1 ? '' : 's'} ago`;
return 'just now';
};
const results = await Promise.all(
workflows.map(async (workflow) => {
const run = await getWorkflowRun(workflow);
if (!run) return `⏳ ${workflow} - no runs yet`;
const emoji = statusEmoji(run.status, run.conclusion);
const runDate = new Date(run.created_at);
const ago = timeAgo(runDate);
return `${emoji} [${workflow}](${run.html_url}) - ${ago}`;
})
);
const report = `## Workflow Status\n\n${results.map(r => `- ${r}`).join('\n')}`;
const allPassed = !results.some(r => r.includes('💀'));
await core.summary.addRaw(report).write();
core.setOutput('all_passed', allPassed);
console.log(report);
if (!allPassed) core.warning('Some workflows have failed');