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

[ci] Add workflow to auto-update download count in README #610

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

MysteryBlokHed
Copy link
Member

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.

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.
@MysteryBlokHed MysteryBlokHed changed the title [ci] Add workflow to auto-update downloads [ci] Add workflow to auto-update download count in README Dec 2, 2024
Copy link

netlify bot commented Dec 2, 2024

Deploy Preview for colorjs ready!

Name Link
🔨 Latest commit 171842a
🔍 Latest deploy log https://app.netlify.com/sites/colorjs/deploys/676e516a25a11900085b12d5
😎 Deploy Preview https://deploy-preview-610--colorjs.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

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))
Copy link
Member

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.

Copy link
Member Author

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

Copy link
Member

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.

Copy link
Member Author

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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants