Skip to content

Commit 78bf65c

Browse files
authored
Add workflow to update clone statistics
1 parent 59f7fc2 commit 78bf65c

File tree

1 file changed

+35
-0
lines changed

1 file changed

+35
-0
lines changed
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
name: Update clone stats
2+
3+
on:
4+
schedule:
5+
- cron: "0 */12 * * *"
6+
workflow_dispatch:
7+
8+
jobs:
9+
update-clones:
10+
runs-on: ubuntu-latest
11+
steps:
12+
- name: Checkout repo
13+
uses: actions/checkout@v4
14+
15+
- name: Get clone stats
16+
run: |
17+
OWNER=${GITHUB_REPOSITORY%/*}
18+
REPO=${GITHUB_REPOSITORY#*/}
19+
curl -s \
20+
-H "Accept: application/vnd.github+json" \
21+
-H "Authorization: Bearer ${{ secrets.CLONE_STATS_TOKEN }}" \
22+
https://api.github.com/repos/$OWNER/$REPO/traffic/clones \
23+
> clones.json
24+
25+
- name: Commit changes
26+
run: |
27+
if git diff --quiet; then
28+
echo "No changes."
29+
exit 0
30+
fi
31+
git config user.name "github-actions[bot]"
32+
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
33+
git add clones.json
34+
git commit -m "Update clone stats"
35+
git push

0 commit comments

Comments
 (0)