-
-
Notifications
You must be signed in to change notification settings - Fork 83
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
[ci] Add workflow to auto-update download count in README #610
base: main
Are you sure you want to change the base?
Conversation
This workflow runs a bash script to pull the latest download count from npm, and update the README.md number if the new value is larger.
✅ Deploy Preview for colorjs ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
downloads=$(curl https://api.npmjs.org/downloads/point/1970-01-01:$(date -d '+1 day' +"%Y-%m-%d")/colorjs.io | jq -r .downloads) | ||
echo "Latest download count: $downloads" | ||
# into millions | ||
downloads=$((downloads / 1000000)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this also round? I'm not very familiar with these and can't tell where the number of downloads is rounded.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This code will just truncate the number instead of rounding to the nearest million (eg. 5,999,999 downloads would become be 5 million). I can make it round instead, if preferred
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Truncating is probably fine, rounding might be better if easy.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I just changed it to round instead of truncate, but I've also just realized that the README says "over 10 million total downloads," so it might be a bit misleading to round? I'm not sure how important that is, but figured it's worth mentioning
Makes the regex match look for the exact same string as sed does. Probably won't actually matter, but doesn't hurt to do.
Briefly discussed in #609
This workflow runs a bash script to pull the latest download count from npm, and update the README.md number if the new value is larger.
Currently, it's set up to run daily.