From 257ec9e66d789eac685fe274d707dfeba364f300 Mon Sep 17 00:00:00 2001 From: Your Name Date: Mon, 26 Jan 2026 14:45:43 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=96=B0=E5=A2=9E=20Docker=20Pulls=20?= =?UTF-8?q?=E6=AD=B7=E5=8F=B2=E8=A8=98=E9=8C=84=E5=B7=A5=E4=BD=9C=E6=B5=81?= =?UTF-8?q?=E7=A8=8B=EF=BC=8C=E5=AE=9A=E6=9C=9F=E6=8A=93=E5=8F=96=E4=B8=A6?= =?UTF-8?q?=E7=94=9F=E6=88=90=20SVG=20=E5=9C=96=E8=A1=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/docker-pulls-history.yml | 76 ++++++++++++++++++++++ 1 file changed, 76 insertions(+) create mode 100644 .github/workflows/docker-pulls-history.yml diff --git a/.github/workflows/docker-pulls-history.yml b/.github/workflows/docker-pulls-history.yml new file mode 100644 index 0000000..6e8e0bd --- /dev/null +++ b/.github/workflows/docker-pulls-history.yml @@ -0,0 +1,76 @@ +name: Docker Pulls History + +on: + schedule: + - cron: "0 0 * * *" # 每天 UTC 00:00(台灣 08:00) + workflow_dispatch: + +jobs: + track: + runs-on: ubuntu-latest + + steps: + - name: Checkout repo + uses: actions/checkout@v4 + + - name: Fetch Docker Hub pull count + run: | + set -e + DATE=$(date -u +"%Y-%m-%d") + PULLS=$(curl -s https://hub.docker.com/v2/repositories/convertx/convertx-cn/ | jq '.pull_count') + echo "$DATE,$PULLS" >> metrics/docker-pulls.csv + + - name: Generate SVG chart + run: | + node <<'EOF' + const fs = require('fs'); + + const csv = fs.readFileSync('metrics/docker-pulls.csv', 'utf8') + .trim() + .split('\n') + .slice(1); + + const dates = csv.map(r => r.split(',')[0]); + const pulls = csv.map(r => Number(r.split(',')[1])); + + const svg = ` + + + + + + + Docker Pull History – convertx/convertx-cn + + + ${pulls.map((v, i) => { + if (i === 0) return ''; + const x1 = 60 + (i - 1) * (680 / (pulls.length - 1)); + const y1 = 340 - (pulls[i - 1] / Math.max(...pulls)) * 260; + const x2 = 60 + i * (680 / (pulls.length - 1)); + const y2 = 340 - (v / Math.max(...pulls)) * 260; + return ``; + }).join('')} + + ${dates[0]} + ${dates[dates.length - 1]} + + ${Math.max(...pulls).toLocaleString()} + + `; + + fs.writeFileSync('metrics/docker-pulls-history.svg', svg); + EOF + + - name: Commit and push + run: | + git config user.name "github-actions" + git config user.email "actions@github.com" + git add metrics + git commit -m "chore(metrics): update docker pull history" || exit 0 + git push