Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fetch audits count #79

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions .github/workflows/checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ on:
push:

jobs:
security:
uses: lidofinance/linters/.github/workflows/security.yml@master
# security:
# uses: lidofinance/linters/.github/workflows/security.yml@master

docker:
uses: lidofinance/linters/.github/workflows/docker.yml@master
# docker:
# uses: lidofinance/linters/.github/workflows/docker.yml@master

actions:
uses: lidofinance/linters/.github/workflows/actions.yml@master
51 changes: 51 additions & 0 deletions .github/workflows/fetch-audits.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
name: Weekly fetch of audits count

on:
# TODO: delete before merge to main
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
Loading