-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
3dcd930
commit 0bec49d
Showing
1 changed file
with
46 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
name: Weekly fetch of audits count | ||
|
||
on: | ||
push: | ||
schedule: | ||
# At 12:00 on Monday | ||
- cron: '0 12 * * MON' | ||
|
||
jobs: | ||
run_js_code: | ||
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 JavaScript file | ||
run: | | ||
cat <<EOF | node | ||
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 |