-
Notifications
You must be signed in to change notification settings - Fork 2
50 lines (39 loc) · 1.2 KB
/
fetch-audits.yml
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
name: Weekly fetch of audits count
on:
push:
schedule:
# At 12:00 on Monday
- cron: '0 12 * * MON'
jobs:
fetch-audits:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Set up Node.js
uses: actions/setup-node@v2
with:
node-version: '18'
- name: Create fetcher script
run: |
cat <<EOF > /tmp/fetch-audits.js
const API_URL = 'https://api.github.com/repos/lidofinance/audits/contents/';
async function countPdfFiles(path = '') {
const response = await fetch(API_URL + path);
const data = await response.json();
let count = 0;
for (const item of data) {
if (item.type === 'file' && item.name.endsWith('.pdf')) {
count++;
} else if (item.type === 'dir') {
count += await countPdfFiles(item.path);
}
}
return count;
}
countPdfFiles().then(count => {
console.log('count', count);
});
EOF
- name: Execute fetcher script
run: node /tmp/fetch-audits.js