-
Notifications
You must be signed in to change notification settings - Fork 16
55 lines (47 loc) · 1.75 KB
/
stats.yml
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
name: Update Weekly GitHub Stats
on:
workflow_dispatch:
# Run every 2 weeks on Monday at 00:00 UTC
schedule:
- cron: '0 0 * * 1/2'
jobs:
update-stats:
runs-on: ubuntu-latest
steps:
- name: Checkout Repository
uses: actions/checkout@v2
- name: Fetch GitHub Stats Clones
id: fetch-clones
run: |
# Fetch GitHub stats using API
curl -L \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer ${{ secrets.STATS_TOKEN }}" \
-H "X-GitHub-Api-Version: 2022-11-28" \
https://api.github.com/repos/ELIXIR-Belgium/elixir-toolkit-theme/traffic/clones > clones-stats.json
cat clones-stats.json
- name: Fetch GitHub Stats Views
id: fetch-views
run: |
curl -L \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer ${{ secrets.STATS_TOKEN }}" \
-H "X-GitHub-Api-Version: 2022-11-28" \
https://api.github.com/repos/ELIXIR-Belgium/elixir-toolkit-theme/traffic/views > views-stats.json
cat views-stats.json
- name: Update Stats File
run: |
CLONES=$(jq '.count' clones-stats.json)
UNIQUECLONES=$(jq '.uniques' clones-stats.json)
VIEWS=$(jq '.count' views-stats.json)
UNIQUEVIEWS=$(jq '.uniques' views-stats.json)
DATE=$(date +'%Y-%m-%d %H:%M:%S')
echo "$DATE,$CLONES,$UNIQUECLONES,$VIEWS,$UNIQUEVIEWS" >> stats.csv
- name: Commit and Push Changes
uses: EndBug/add-and-commit@v7
with:
message: "Update weekly GitHub stats"
add: "stats.csv"
branch: stats
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}