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