Skip to content

Libraries data automatic update #874

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

Merged
merged 3 commits into from
Aug 14, 2025
Merged
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
36 changes: 36 additions & 0 deletions .github/workflows/update-libraries.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: Update libraries stars count (test)
on:
push:
branches: [stars-ci-test]
workflow_dispatch:


jobs:
update-stars:
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Checkout repo
uses: actions/checkout@v4
with:
persist-credentials: false
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 20
- name: Install dependencies
run: npm install node-fetch@2
- name: Update stars in libraries-next.json
run: node scripts/updateStars.js
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Commit and push changes
run: |
git config --global user.name 'javier-okta'
git config --global user.email '[email protected]'
git add .
git commit -m "chore: update stars count [skip ci]" || echo "No changes to commit"
git push
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
158 changes: 158 additions & 0 deletions scripts/example-repos.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,158 @@
{
"dot-net": {
"id": "dot-net",
"name": ".NET",
"uniqueClass": "net",
"image": "/img/1.svg",
"bgColor": "rgb(42, 168, 229)",
"libs": [
{
"minimumVersion": null,
"support": {
"sign": true,
"verify": true,
"iss": true,
"sub": true,
"aud": true,
"exp": true,
"nbf": true,
"iat": true,
"jti": true,
"hs256": true,
"hs384": true,
"hs512": true,
"rs256": true,
"rs384": true,
"rs512": true,
"es256": true,
"es384": true,
"es512": true,
"ps256": true,
"ps384": true,
"ps512": true
},
"authorUrl": "https://www.microsoft.com",
"authorName": "Microsoft",
"gitHubRepoPath": "AzureAD/azure-activedirectory-identitymodel-extensions-for-dotnet",
"repoUrl": "https://github.com/MSOpenTech/azure-activedirectory-identitymodel-extensions-for-dotnet",
"installCommandMarkdown": [
"Install-Package",
"[System.IdentityModel.Tokens.Jwt](https://www.nuget.org/packages/System.IdentityModel.Tokens.Jwt/)"
],
"stars": 1115
},
{
"minimumVersion": null,
"support": {
"sign": true,
"verify": true,
"iss": true,
"sub": true,
"aud": true,
"exp": true,
"nbf": true,
"iat": true,
"jti": false,
"hs256": true,
"hs384": true,
"hs512": true,
"rs256": true,
"rs384": true,
"rs512": true,
"es256": true,
"es384": true,
"es512": true,
"ps256": false,
"ps384": false,
"ps512": false
},
"authorUrl": "https://github.com/jwt-dotnet/jwt",
"authorName": "Alexander Batishchev",
"gitHubRepoPath": "jwt-dotnet/jwt",
"repoUrl": "https://github.com/jwt-dotnet/jwt",
"installCommandMarkdown": [
"Install-Package",
"[JWT.NET](https://www.nuget.org/packages/JWT)"
],
"stars": 2109
}
]
},
"swift": {
"id": "swift",
"name": "Swift",
"uniqueClass": "swift",
"image": "/img/15.svg",
"bgColor": "rgb(234, 45, 46)",
"libs": [
{
"minimumVersion": null,
"support": {
"sign": true,
"verify": true,
"iss": true,
"sub": false,
"aud": true,
"exp": true,
"nbf": true,
"iat": true,
"jti": false,
"hs256": true,
"hs384": true,
"hs512": true,
"rs256": false,
"rs384": false,
"rs512": false,
"es256": false,
"es384": false,
"es512": false,
"ps256": false,
"ps384": false,
"ps512": false
},
"authorUrl": "https://github.com/kylef",
"authorName": "Kyle Fuller",
"gitHubRepoPath": "kylef/JSONWebToken.swift",
"repoUrl": "https://github.com/kylef/JSONWebToken.swift",
"installCommandMarkdown": [
"pod 'JSONWebToken'"
],
"stars": 751
},
{
"minimumVersion": null,
"support": {
"sign": true,
"verify": true,
"iss": true,
"sub": true,
"aud": true,
"exp": true,
"nbf": true,
"iat": true,
"jti": true,
"hs256": true,
"hs384": true,
"hs512": true,
"rs256": true,
"rs384": true,
"rs512": true,
"es256": true,
"es384": true,
"es512": true,
"ps256": false,
"ps384": false,
"ps512": false
},
"authorUrl": "https://github.com/vapor",
"authorName": "Vapor",
"gitHubRepoPath": "vapor/jwt-kit",
"repoUrl": "https://github.com/vapor/jwt-kit",
"installCommandMarkdown": [
".package(url: \"https://github.com/vapor/jwt-kit.git\", from: \"4.0.0\")"
],
"stars": 250
}
]
}
}
36 changes: 36 additions & 0 deletions scripts/updateStars.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import fs from "fs"
import path from "path"

const filePath = path.join(process.cwd(), "/scripts/example-repos.json")
const reposGroup = JSON.parse(fs.readFileSync(filePath, "utf-8"))

async function getStars(repoUrl) {
const match = repoUrl.match(/github\.com\/([^/]+)\/([^/]+)(?:\/|$)/)
if(!match) throw new Error(`Invalid github repo URL: ${repoUrl}`)
const [, owner, repo] = match
const res = await fetch(`https://api.github.com/repos/${owner}/${repo}`, {
headers: {
Accept: "application/vnd.github+json"
}
})
if(!res.ok) throw new Error(`${repoUrl} -> ${res.status} ${res.statusText}`)
const data = await res.json()
return data.stargazers_count ?? null
}

(async () => {
const objectEntries = Object.values(reposGroup)
for(const group of objectEntries) {
for(const lib of group.libs) {
try {
const stars = await getStars(lib.repoUrl)
lib.stars = stars
console.log(`✅ ${lib.repoUrl} -> ${stars}`)
} catch(e) {
lib.stars = null
console.error(`❌ ${lib.repoUrl}: ${e.message}`)
}
}
}
fs.writeFileSync(filePath, JSON.stringify(reposGroup, null, 2) + "\n")
})()