mirror of
https://github.com/ivuorinen/actions.git
synced 2026-03-12 09:58:05 +00:00
fix: security-metrics
This commit is contained in:
13
.github/workflows/security-metrics.yml
vendored
13
.github/workflows/security-metrics.yml
vendored
@@ -29,6 +29,9 @@ jobs:
|
|||||||
uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1
|
uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1
|
||||||
with:
|
with:
|
||||||
script: |
|
script: |
|
||||||
|
const fs = require('fs');
|
||||||
|
|
||||||
|
async function collectMetrics() {
|
||||||
const metrics = {
|
const metrics = {
|
||||||
timestamp: new Date().toISOString(),
|
timestamp: new Date().toISOString(),
|
||||||
weekly: {
|
weekly: {
|
||||||
@@ -84,7 +87,7 @@ jobs:
|
|||||||
});
|
});
|
||||||
|
|
||||||
metrics.weekly.fixes.submitted = fixPRs.data.length;
|
metrics.weekly.fixes.submitted = fixPRs.data.length;
|
||||||
const mergedPRs = fixPRs.data.filter(pr => pr.merged);
|
const mergedPRs = fixPRs.data.filter(pr => pr.merged_at);
|
||||||
metrics.weekly.fixes.merged = mergedPRs.length;
|
metrics.weekly.fixes.merged = mergedPRs.length;
|
||||||
|
|
||||||
// Calculate mean time to fix only if there are merged PRs
|
// Calculate mean time to fix only if there are merged PRs
|
||||||
@@ -101,24 +104,24 @@ jobs:
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Save metrics
|
// Save metrics
|
||||||
const fs = require('fs');
|
|
||||||
fs.writeFileSync('security-metrics.json', JSON.stringify(metrics, null, 2));
|
fs.writeFileSync('security-metrics.json', JSON.stringify(metrics, null, 2));
|
||||||
|
|
||||||
// Generate report
|
// Generate report
|
||||||
const report = generateMetricsReport(metrics);
|
const report = generateReport(metrics);
|
||||||
|
|
||||||
// Create/update metrics dashboard
|
// Create/update metrics dashboard
|
||||||
await github.rest.issues.create({
|
await github.rest.issues.create({
|
||||||
owner: context.repo.owner,
|
owner: context.repo.owner,
|
||||||
repo: context.repo.repo,
|
repo: context.repo.repo,
|
||||||
title: '📊 Weekly Security Metrics Report',
|
title: '📊 Weekly Security Metrics Report',
|
||||||
body: generateReport(metrics),
|
body: report,
|
||||||
labels: ['metrics', 'security']
|
labels: ['metrics', 'security']
|
||||||
});
|
});
|
||||||
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
core.setFailed(`Failed to collect metrics: ${error.message}`);
|
core.setFailed(`Failed to collect metrics: ${error.message}`);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function generateReport(metrics) {
|
function generateReport(metrics) {
|
||||||
const formatDuration = (hours) => {
|
const formatDuration = (hours) => {
|
||||||
@@ -177,3 +180,5 @@ jobs:
|
|||||||
|
|
||||||
return summary.join('\n');
|
return summary.join('\n');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
collectMetrics();
|
||||||
|
|||||||
Reference in New Issue
Block a user