File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ name : Update traffic badge
2+
3+ on :
4+ push : # update when you push to your fork/branch
5+ branches : ["**"]
6+ schedule :
7+ - cron : " 7 3 * * *" # daily
8+ workflow_dispatch :
9+
10+ permissions :
11+ contents : write
12+
13+ jobs :
14+ update :
15+ runs-on : ubuntu-latest
16+ steps :
17+ - uses : actions/checkout@v4
18+
19+ - name : Update badge.json with views (last 14d)
20+ uses : actions/github-script@v7
21+ with :
22+ script : |
23+ // Fetch 14-day views for THIS repo (your fork until merged)
24+ const { data } = await github.request('GET /repos/{owner}/{repo}/traffic/views', {
25+ owner: context.repo.owner,
26+ repo: context.repo.repo
27+ });
28+
29+ const total = data?.count ?? 0;
30+ const payload = {
31+ schemaVersion: 1,
32+ label: "views (14d)",
33+ message: String(total)
34+ };
35+
36+ const fs = require('fs');
37+ fs.writeFileSync('badge.json', JSON.stringify(payload));
38+
39+ - name : Commit and push if changed
40+ run : |
41+ git config user.name "github-actions"
42+ git config user.email "[email protected] " 43+ git add badge.json
44+ git diff --quiet || git commit -m "Update traffic badge"
45+ git push
Original file line number Diff line number Diff line change 77[ ![ NSF-2126413] ( https://img.shields.io/badge/NSF-2126413-blue.svg )] ( https://nsf.gov/awardsearch/showAward?AWD_ID=2126413 )
88[ ![ Zenodo DOI] ( https://zenodo.org/badge/DOI/10.5281/zenodo.11081647.svg )] ( https://doi.org/10.5281/zenodo.11081647 )
99[ ![ JOSS DOI] ( https://joss.theoj.org/papers/10.21105/joss.06742/status.svg )] ( https://doi.org/10.21105/joss.06742 )
10- [ ![ Hits ] ( https://hits.seeyoufarm.com/api/count/incr/badge.svg?url=https%3A%2F%2Fgithub.com%2FCloud-Drift%2Fclouddrift&count_bg=%2368C563&title_bg=%23555555&icon=&icon_color=%23E7E7E7&title=hits&edge_flat=false )] ( https://hits.seeyoufarm.com )
10+ ![ Views (14d) ] [ traffic-badge ]
1111
1212### 📦 Distributions
1313[ ![ Available on conda-forge] ( https://anaconda.org/conda-forge/clouddrift/badges/version.svg?style=flat-square )] ( https://anaconda.org/conda-forge/clouddrift/ )
@@ -169,3 +169,5 @@ best to help you.
169169
170170Please create a new issue [ here] ( https://github.com/Cloud-Drift/clouddrift/issues/new )
171171and provide as much detail as possible about your problem or question.
172+
173+ [ traffic-badge ] : https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/selipot/clouddrift/hit-button/badge.json&cacheSeconds=3600
Original file line number Diff line number Diff line change 1+ { "schemaVersion" : 1 , "label" : " views (14d)" , "message" : " …" }
You can’t perform that action at this time.
0 commit comments