-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
59 lines (49 loc) · 1.27 KB
/
index.js
File metadata and controls
59 lines (49 loc) · 1.27 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
// main.js
const fs = require('fs');
const path = require('path');
const core = require('@actions/core');
const contractsDir = './contracts';
fs.readdir(contractsDir, (err, files) => {
if (err) throw err;
let results = [];
let html = `
<style>
table {
border-collapse: collapse;
width: 100%;
}
th, td {
border: 1px solid #ddd;
padding: 8px;
}
tr:nth-child(even) {
background-color: #f2f2f2;
}
th {
padding-top: 12px;
padding-bottom: 12px;
text-align: left;
background-color: #4CAF50;
color: white;
}
</style>
<table>
<tr>
<th>Contract Name</th>
<th>Number of Lines</th>
</tr>
`;
files.forEach(file => {
const filePath = path.join(contractsDir, file);
const fileContent = fs.readFileSync(filePath, 'utf8');
const lineCount = fileContent.split('\n').length;
results.push({[file]: lineCount});
html += `<tr><td>${file}</td><td>${lineCount}</td></tr>`;
});
html += '</table>';
console.log('Line counts:', results);
console.log('HTML:', html);
// Set outputs for other GitHub Actions steps
core.setOutput('lineCounts', JSON.stringify(results));
core.setOutput('html', html);
});