File tree 3 files changed +50
-90
lines changed
3 files changed +50
-90
lines changed Original file line number Diff line number Diff line change
1
+ name : Clone Stats and Badge Update
2
+
3
+ on :
4
+ schedule :
5
+ - cron : " 0 0 * * *" # Run daily at midnight
6
+ workflow_dispatch :
7
+
8
+ jobs :
9
+ update-stats-and-badge :
10
+ runs-on : ubuntu-latest
11
+ steps :
12
+ - uses : actions/checkout@v2
13
+
14
+ - name : Setup GitHub CLI
15
+ env :
16
+ GH_TOKEN : ${{ secrets.GH_TOKEN }}
17
+ run : |
18
+ echo "$GH_TOKEN" | gh auth login --with-token
19
+
20
+ - name : Get Latest Clone Count
21
+ run : |
22
+ gh api repos/${{ github.repository }}/traffic/clones > latest_clones.json
23
+
24
+ - name : Update Historical Data
25
+ env :
26
+ GIST_ID : ${{ secrets.GIST_ID }}
27
+ run : |
28
+ gh gist get $GIST_ID > previous_clones.json
29
+ jq -s '.[0] * .[1]' previous_clones.json latest_clones.json > clone.json
30
+ gh gist edit $GIST_ID clone.json
31
+
32
+ - name : Push Updated Stats
33
+ run : |
34
+ gh api -X PUT repos/${{ github.repository }}/traffic/clones --input clone.json
35
+
36
+ - name : Update README Badge
37
+ run : |
38
+ CLONE_COUNT=$(cat latest_clones.json | jq '.count')
39
+ BADGE_URL="https://img.shields.io/badge/Clones-${CLONE_COUNT}-brightgreen"
40
+ sed -i "s|!\[Clone Count\]([^)]*)||" README.md
41
+
42
+ - name : Commit and Push Badge Update
43
+ run : |
44
+ git config --global user.name "GitHub Action"
45
+ git config --global user.email "[email protected] "
46
+ git add README.md
47
+ git commit -m "Update clone count badge"
48
+ git push
Load Diff This file was deleted.
Original file line number Diff line number Diff line change @@ -4,6 +4,8 @@ A Crystal shard for creating human-readable URLs and slugs. FriendlyId lets you
4
4
5
5
[ ![ Crystal Test] ( https://github.com/dcalixto/friendly_id/actions/workflows/crystal-test.yml/badge.svg?branch=master )] ( https://github.com/dcalixto/friendly_id/actions/workflows/crystal-test.yml )
6
6
7
+ ![ Clone Count] ( https://img.shields.io/badge/Clones-0-brightgreen )
8
+
7
9
## Installation
8
10
9
11
1 . Add the dependency to your ` shard.yml ` :
You can’t perform that action at this time.
0 commit comments