Skip to content

Commit 6b91dd1

Browse files
committed
ci: replace clone-count with jgehrcke/github-repo-stats
- Replace fragile MShawon/github-clone-count-badge (unversioned curl) with jgehrcke/github-repo-stats (SHA-pinned, proper deduplication) - Add schneegans/dynamic-badges-action for shields.io endpoint badge - Pin all actions to full commit SHA (supply chain hardening) - Add permissions, concurrency, and timeout-minutes - Remove obsolete CLONE.md - Rename workflow file to repo-stats.yml
1 parent d359784 commit 6b91dd1

4 files changed

Lines changed: 72 additions & 80 deletions

File tree

.github/workflows/clone-count.yml

Lines changed: 0 additions & 64 deletions
This file was deleted.

.github/workflows/repo-stats.yml

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
name: GitHub Repo Stats
2+
3+
on:
4+
schedule:
5+
- cron: '0 23 * * *'
6+
workflow_dispatch:
7+
8+
permissions:
9+
contents: read
10+
11+
concurrency:
12+
group: repo-stats
13+
cancel-in-progress: false
14+
15+
jobs:
16+
repo-stats:
17+
runs-on: ubuntu-latest
18+
timeout-minutes: 15
19+
if: github.repository == 'sap/e-mobility-charging-stations-simulator'
20+
21+
steps:
22+
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
23+
24+
- name: Validate configuration
25+
run: |
26+
if [ -z "$GIST_ID" ]; then
27+
echo "::error::GIST_ID variable is not configured"
28+
exit 1
29+
fi
30+
if [ -z "$SECRET_TOKEN" ]; then
31+
echo "::error::SECRET_TOKEN secret is not configured"
32+
exit 1
33+
fi
34+
env:
35+
GIST_ID: ${{ vars.GIST_ID }}
36+
SECRET_TOKEN: ${{ secrets.SECRET_TOKEN }}
37+
38+
- name: Collect repository traffic stats
39+
uses: jgehrcke/github-repo-stats@b1ef746a160025ee47390ea5e332b09a7acb3e80 # v1.4.2+
40+
with:
41+
ghtoken: ${{ secrets.SECRET_TOKEN }}
42+
repository: ${{ github.repository }}
43+
databranch: github-repo-stats
44+
45+
- name: Extract total clone count
46+
id: clones
47+
run: |
48+
git fetch origin github-repo-stats
49+
mkdir -p /tmp/stats-data
50+
git archive origin/github-repo-stats | tar -x -C /tmp/stats-data 2>/dev/null || true
51+
CSV_FILE=$(find /tmp/stats-data -path '*/ghrs-data/views_clones_aggregate.csv' | head -1)
52+
if [ -n "$CSV_FILE" ] && [ -f "$CSV_FILE" ]; then
53+
TOTAL=$(awk -F',' 'NR>1 {sum+=$2} END {print sum}' "$CSV_FILE")
54+
echo "count=$TOTAL" >> "$GITHUB_OUTPUT"
55+
else
56+
echo "::warning::Could not locate views_clones_aggregate.csv - skipping badge update"
57+
echo "skip=true" >> "$GITHUB_OUTPUT"
58+
fi
59+
60+
- name: Update clone count badge
61+
if: steps.clones.outputs.skip != 'true'
62+
uses: schneegans/dynamic-badges-action@0e50b8bad39e7e1afd3e4e9c2b7dd145fad07501 # v1.8.0
63+
with:
64+
auth: ${{ secrets.SECRET_TOKEN }}
65+
gistID: ${{ vars.GIST_ID }}
66+
filename: clone.json
67+
label: Clones
68+
message: ${{ steps.clones.outputs.count }}
69+
color: brightgreen
70+
logoColor: white
71+
namedLogo: github

CLONE.md

Lines changed: 0 additions & 15 deletions
This file was deleted.

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
<div align="center">
99

10-
[![GitHub Clones](https://img.shields.io/badge/dynamic/json?color=brightgreen&label=Clone&query=count&url=https://gist.githubusercontent.com/jerome-benoit/c7c669b881d5b27dc0b44a639504ff93/raw/clone.json&logo=github)](https://github.com/SAP/e-mobility-charging-stations-simulator/graphs/traffic)
10+
[![GitHub Clones](https://img.shields.io/endpoint?url=https://gist.githubusercontent.com/jerome-benoit/c7c669b881d5b27dc0b44a639504ff93/raw/clone.json&logo=github)](https://github.com/SAP/e-mobility-charging-stations-simulator/graphs/traffic)
1111
[![GitHub commit activity (main)](https://img.shields.io/github/commit-activity/m/SAP/e-mobility-charging-stations-simulator/main?color=brightgreen&logo=github)](https://github.com/SAP/e-mobility-charging-stations-simulator/graphs/commit-activity)
1212
[![CI workflow](https://github.com/SAP/e-mobility-charging-stations-simulator/actions/workflows/ci.yml/badge.svg)](https://github.com/SAP/e-mobility-charging-stations-simulator/actions/workflows/ci.yml)
1313
[![REUSE status](https://api.reuse.software/badge/github.com/SAP/e-mobility-charging-stations-simulator)](https://api.reuse.software/info/github.com/SAP/e-mobility-charging-stations-simulator)

0 commit comments

Comments
 (0)