Stars on Gitea: a GitHub token from STARS_GITHUB_TOKEN when set, anonymous otherwise; links to the Gitea repo
This commit is contained in:
3 files changed
+8
-8
No files matched your search
@@ -49,7 +49,8 @@ jobs:
|
||||
- run: pnpm install --frozen-lockfile
|
||||
- run: pnpm run update-stars
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
# A GitHub token, optional: this server's own token means nothing to GitHub.
|
||||
GITHUB_TOKEN: ${{ secrets.STARS_GITHUB_TOKEN }}
|
||||
- run: pnpm validate
|
||||
- name: Commit stars
|
||||
run: |
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
# Ely GPUI Showcases
|
||||
|
||||
Apps built with [Ely GPUI Components](https://github.com/ZacharyZhang-NY/Ely-GPUI-Components). The catalog feeds the Showcase page on the Ely site.
|
||||
Apps built with [Ely GPUI Components](https://git.zacharyzhang.com/ZacharyZhang-NY/Ely-GPUI-Components). The catalog feeds the Showcase page on the Ely site.
|
||||
|
||||
## Submit an app
|
||||
|
||||
@@ -59,7 +59,7 @@ Unknown fields fail validation.
|
||||
|
||||
## Stars
|
||||
|
||||
On every push to `main` and each Monday, CI asks GitHub for each GitHub source's stars and commits any change. `starsUpdatedAt` moves only when the count does. `pnpm run update-stars` does the same locally with `GITHUB_TOKEN` set.
|
||||
On every push to `main` and each Monday, CI asks GitHub for each GitHub source's stars and commits any change. `starsUpdatedAt` moves only when the count does. It signs in with the `STARS_GITHUB_TOKEN` secret when set, a GitHub token, and asks anonymously otherwise. `pnpm run update-stars` does the same locally, `GITHUB_TOKEN` optional.
|
||||
|
||||
## How the site uses this
|
||||
|
||||
|
||||
+4
-5
@@ -20,13 +20,12 @@ export async function refresh(root, get, now) {
|
||||
return changed;
|
||||
}
|
||||
|
||||
/** A repository's stars from GitHub's API. */
|
||||
/** A repository's stars from GitHub's API, signed in when GITHUB_TOKEN holds a GitHub token. */
|
||||
async function stargazers({ owner, repo }) {
|
||||
const token = process.env.GITHUB_TOKEN;
|
||||
if (!token) throw new Error("stars: GITHUB_TOKEN is not set");
|
||||
const res = await fetch(`https://api.github.com/repos/${owner}/${repo}`, {
|
||||
headers: { accept: "application/vnd.github+json", authorization: `Bearer ${token}`, "x-github-api-version": "2022-11-28" },
|
||||
});
|
||||
const headers = { accept: "application/vnd.github+json", "x-github-api-version": "2022-11-28" };
|
||||
if (token) headers.authorization = `Bearer ${token}`;
|
||||
const res = await fetch(`https://api.github.com/repos/${owner}/${repo}`, { headers });
|
||||
if (!res.ok) throw new Error(`stars: ${owner}/${repo} answered ${res.status} ${await res.text()}`);
|
||||
return (await res.json()).stargazers_count;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user