mirror of
https://github.com/louislam/uptime-kuma.git
synced 2026-08-07 11:34:58 +00:00
Add a script to update the download stats.
@@ -0,0 +1,33 @@
|
||||
name: Update Download Stats
|
||||
|
||||
on:
|
||||
workflow_dispatch:
|
||||
schedule:
|
||||
- cron: '0 0 1 */2 *'
|
||||
|
||||
jobs:
|
||||
update:
|
||||
runs-on: ubuntu-latest
|
||||
if: github.repository == 'louislam/uptime-kuma-wiki'
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Setup Deno
|
||||
uses: denoland/setup-deno@v2
|
||||
with:
|
||||
deno-version: lts
|
||||
|
||||
- name: Run update task
|
||||
run: deno task update-download-stats
|
||||
|
||||
- name: Configure Git
|
||||
run: |
|
||||
git config user.name "github-actions[bot]"
|
||||
git config user.email "github-actions[bot]@users.noreply.github.com"
|
||||
|
||||
- name: Commit and push changes
|
||||
run: |
|
||||
git add -A
|
||||
git commit -m "chore: update download stats"
|
||||
git push origin master
|
||||
+1
@@ -18,6 +18,7 @@ You could make a pull request in this wiki repo: https://github.com/louislam/upt
|
||||
|
||||
[](https://star-history.com/#louislam/uptime-kuma&Date)
|
||||
|
||||
- (2026-06-29) ⭐88,559 🐳(docker.io) 162,902,219 + (ghcr.io) 6,119,747 = 169,021,966
|
||||
- (2026-04-28) ⭐86,003 🐳(docker.io) 151,609,128 + (ghcr.io) 4,472,641 = 156,081,769
|
||||
- (2025-12-20) ⭐79,988 🐳(docker.io) 133,830,916 + (ghcr.io) 2,485,241
|
||||
- (2025-10-20) ⭐76,177 🐳127,034,842 + 1,560,702
|
||||
|
||||
+4
-1
@@ -1,8 +1,11 @@
|
||||
{
|
||||
"tasks": {
|
||||
"update-unofficial-apps": "deno run --allow-all src/update-unofficial-apps.ts"
|
||||
"update-unofficial-apps": "deno run --allow-all src/update-unofficial-apps.ts",
|
||||
"update-download-stats": "deno run --allow-all src/update-download-stats.ts"
|
||||
},
|
||||
|
||||
"lock": false,
|
||||
|
||||
// Run `deno fmt` to format
|
||||
"fmt": {
|
||||
"indentWidth": 4,
|
||||
|
||||
@@ -0,0 +1,59 @@
|
||||
import * as cheerio from "npm:cheerio@~1.2.0";
|
||||
|
||||
const today = new Date();
|
||||
const dateStr = today.toISOString().slice(0, 10);
|
||||
|
||||
async function fetchJSON(url: string) {
|
||||
const res = await fetch(url);
|
||||
if (!res.ok) throw new Error(`HTTP ${res.status}: ${url}`);
|
||||
return res.json();
|
||||
}
|
||||
|
||||
// GitHub stars
|
||||
const repo = await fetchJSON("https://api.github.com/repos/louislam/uptime-kuma");
|
||||
const stars: number = repo.stargazers_count;
|
||||
|
||||
// Docker Hub pulls
|
||||
const dockerHub = await fetchJSON("https://hub.docker.com/v2/repositories/louislam/uptime-kuma/");
|
||||
const dockerPulls: number = dockerHub.pull_count;
|
||||
|
||||
|
||||
// GHCR pulls - scraped from the package page HTML
|
||||
const ghcrPage = await fetch("https://github.com/louislam/uptime-kuma/pkgs/container/uptime-kuma");
|
||||
const ghcrHtml = await ghcrPage.text();
|
||||
const $ = cheerio.load(ghcrHtml);
|
||||
const title = $('span:contains("Total downloads")').siblings("h3").attr("title");
|
||||
let ghcrPulls = 0;
|
||||
if (title) {
|
||||
ghcrPulls = parseInt(title, 10);
|
||||
} else {
|
||||
console.error("Warning: could not parse GHCR total downloads from HTML");
|
||||
}
|
||||
|
||||
const fmt = (n: number) => n.toLocaleString("en-US");
|
||||
|
||||
const dockerStr = `🐳(docker.io) ${fmt(dockerPulls)}`;
|
||||
const ghcrStr = `+ (ghcr.io) ${fmt(ghcrPulls)}`;
|
||||
const total = dockerPulls + ghcrPulls;
|
||||
const line = `- (${dateStr}) ⭐${fmt(stars)} ${dockerStr} ${ghcrStr} = ${fmt(total)}`;
|
||||
|
||||
// Insert into Home.md at top of History list
|
||||
const text = await Deno.readTextFile("Home.md");
|
||||
const historyIdx = text.indexOf("## History");
|
||||
if (historyIdx === -1) {
|
||||
console.error("Error: ## History section not found");
|
||||
Deno.exit(1);
|
||||
}
|
||||
|
||||
const afterHeading = text.slice(historyIdx);
|
||||
const firstListItemMatch = afterHeading.search(/\n- /);
|
||||
if (firstListItemMatch === -1) {
|
||||
console.error("Error: No list items found in History section");
|
||||
Deno.exit(1);
|
||||
}
|
||||
|
||||
const insertPos = historyIdx + firstListItemMatch + 1;
|
||||
const newText = text.slice(0, insertPos) + line + "\n" + text.slice(insertPos);
|
||||
|
||||
await Deno.writeTextFile("Home.md", newText);
|
||||
console.log(`Added: ${line}`);
|
||||
Reference in New Issue
Block a user