1
1
name : Weekly Clone Stats Email
2
2
3
3
on :
4
- # Every Monday at 08:00 UTC
5
4
schedule :
6
- - cron : ' 0 8 * * 1'
5
+ - cron : ' 0 8 * * 1' # Every Monday at 08:00 UTC
7
6
8
7
pull_request :
9
8
branches :
19
18
- name : Check out code
20
19
uses : actions/checkout@v3
21
20
21
+ - name : Install jq
22
+ run : sudo apt-get update && sudo apt-get install -y jq
23
+
22
24
- name : Fetch Clone Stats
23
25
env :
24
26
GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
@@ -28,53 +30,31 @@ jobs:
28
30
"https://api.github.com/repos/$REPO/traffic/clones" > clone_stats.json
29
31
30
32
- name : Upload Clone Stats
31
- uses : actions/upload-artifact@v4
33
+ uses : actions/upload-artifact@v3
32
34
with :
33
- # This is the name used to identify the artifact
34
35
name : clone-stats
35
- # File(s) or directories you want to upload as the artifact
36
36
path : clone_stats.json
37
37
38
- send-email :
38
+ print-stats :
39
39
needs : fetch-clone-stats
40
40
runs-on : ubuntu-latest
41
41
steps :
42
42
- name : Check out code
43
43
uses : actions/checkout@v3
44
44
45
45
- name : Download Clone Stats
46
- uses : actions/download-artifact@v4
46
+ uses : actions/download-artifact@v3
47
47
with :
48
- # Must match the name used above in actions/upload-artifact
49
48
name : clone-stats
50
- # The path/folder where the artifact is extracted
51
49
path : .
52
50
53
- - name : Parse clone stats
51
+ - name : Print raw JSON
52
+ run : cat clone_stats.json
53
+
54
+ - name : Parse and Print Stats
54
55
id : parse
55
56
run : |
56
57
COUNT=$(jq '.count' clone_stats.json)
57
58
UNIQUES=$(jq '.uniques' clone_stats.json)
58
- echo "count=$COUNT" >> $GITHUB_OUTPUT
59
- echo "uniques=$UNIQUES" >> $GITHUB_OUTPUT
60
-
61
- - name : Send email
62
- uses : dawidd6/action-send-mail@v3
63
- with :
64
- server_address : smtp.sendgrid.net
65
- server_port : 587
66
- secure : true
67
- username : ${{ secrets.SMTP_USERNAME }}
68
- password : ${{ secrets.SMTP_PASSWORD }}
69
- from : ${{ vars.EMAIL_FROM }}
70
- to : ${{ vars.EMAIL_TO }}
71
- subject : " 📊 Weekly GitHub Clone Stats for ${{ github.repository }}"
72
- body : |
73
- Hi,
74
-
75
- Here are the clone stats for *${{ github.repository }}* this week:
76
-
77
- 🔁 Total Clones: ${{ steps.parse.outputs.count }}
78
- 👤 Unique Cloners: ${{ steps.parse.outputs.uniques }}
79
-
80
- – GitHub Bot
59
+ echo "Total Clones: $COUNT"
60
+ echo "Unique Cloners: $UNIQUES"
0 commit comments