Skip to content

Commit be9ee26

Browse files
committed
feat: auto-update star count
1 parent f1dc929 commit be9ee26

5 files changed

Lines changed: 237 additions & 155 deletions

File tree

.env.example

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1 @@
1-
GITHUB_APP_ID=
2-
GITHUB_APP_PRIVATE_KEY=
3-
GITHUB_INSTALLATION_ID=
1+
GITHUB_TOKEN=

.github/workflows/preview-community.yaml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ name: Vercel Preview Community Deployment
22
env:
33
VERCEL_ORG_ID: ${{ secrets.VERCEL_ORG_ID }}
44
VERCEL_PROJECT_ID: ${{ secrets.PREVIEW_VERCEL_PROJECT_ID }}
5+
permissions:
6+
contents: read
57
on:
68
push:
79
branches:
@@ -13,6 +15,16 @@ jobs:
1315
steps:
1416
- name: Checkout the Codebase
1517
uses: actions/checkout@v4
18+
- name: Setup Node.js
19+
uses: actions/setup-node@v4
20+
with:
21+
node-version: '22'
22+
- name: Install dependencies
23+
run: npm ci
24+
- name: Refresh library star counts
25+
run: npm run generate:library-data
26+
env:
27+
GITHUB_TOKEN: ${{ github.token }}
1628
- name: Install Vercel CLI
1729
run: npm install --global vercel@latest
1830
- name: Deploy on Vercel

.github/workflows/production.yaml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,16 @@ name: Vercel Production Deployment
22
env:
33
VERCEL_ORG_ID: ${{ secrets.VERCEL_ORG_ID }}
44
VERCEL_PROJECT_ID: ${{ secrets.VERCEL_PROJECT_ID }}
5+
permissions:
6+
contents: read
57
on:
68
push:
79
branches:
810
- master
911
- production
12+
schedule:
13+
- cron: "0 6 * * 1"
14+
workflow_dispatch:
1015
jobs:
1116
test:
1217
runs-on: ubuntu-latest
@@ -44,6 +49,16 @@ jobs:
4449
steps:
4550
- name: Checkout the Codebase
4651
uses: actions/checkout@v4
52+
- name: Setup Node.js
53+
uses: actions/setup-node@v4
54+
with:
55+
node-version: '22'
56+
- name: Install dependencies
57+
run: npm ci
58+
- name: Refresh library star counts
59+
run: npm run generate:library-data
60+
env:
61+
GITHUB_TOKEN: ${{ github.token }}
4762
- name: Install Vercel CLI
4863
run: npm install --global vercel@latest
4964
- name: Deploy on Vercel

README.md

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -22,32 +22,37 @@ This project uses [`next/font`](https://nextjs.org/docs/basic-features/font-opti
2222

2323
## Generate Data for Libraries page
2424

25-
First, create a GitHub Application.
25+
If GitHub CLI is already authenticated, update the library star counts using
26+
your existing credentials:
2627

27-
Generate a private key for the GitHub application.
28-
29-
Install the application.
28+
```bash
29+
GITHUB_TOKEN="$(gh auth token)" npm run generate:library-data
30+
```
3031

31-
Generate a `.env` file based on the `.env.example` file:
32+
Alternatively, generate a `.env` file based on the `.env.example` file:
3233

3334
```bash
3435
cp .env.example .env
3536
```
3637

37-
Then, you'll need to add the values with your private key, app id and installation id into the `.env`file:
38+
Then, add your personal GitHub access token to the `.env` file:
3839

3940
```bash
40-
GITHUB_APP_ID=
41-
GITHUB_APP_PRIVATE_KEY=
42-
GITHUB_INSTALLATION_ID=
41+
GITHUB_TOKEN=
4342
```
4443

45-
Run the `libraries.js` script to generate the `libraries.json` file:
44+
Then run the generator:
4645

4746
```bash
48-
node libraries.js
47+
npm run generate:library-data
4948
```
5049

50+
Both commands update `src/data/libraries-next.json`.
51+
52+
Production deployments refresh the star counts automatically using the
53+
workflow's built-in GitHub token. The production workflow also runs every
54+
Monday at 06:00 UTC.
55+
5156
## Learn More
5257

5358
To learn more about Next.js, take a look at the following resources:
@@ -65,4 +70,4 @@ Check out our [Next.js deployment documentation](https://nextjs.org/docs/deploym
6570

6671
## License
6772

68-
This project is licensed under the Apache License 2.0 - see the [LICENSE](LICENSE) file for details
73+
This project is licensed under the Apache License 2.0 - see the [LICENSE](LICENSE) file for details

0 commit comments

Comments
 (0)