Weekly clone stats #11
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Weekly Clone Stats Email | |
on: | |
schedule: | |
- cron: '0 8 * * 1' # Every Monday at 08:00 UTC | |
pull_request: | |
branches: | |
- main | |
permissions: | |
contents: read | |
jobs: | |
fetch-clone-stats: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Check out code | |
uses: actions/checkout@v3 | |
- name: Fetch Clone Stats | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
run: | | |
REPO="${{ github.repository }}" | |
curl -L \ | |
-H "Accept: application/vnd.github+json" \ | |
-H "Authorization: Bearer $GITHUB_TOKEN" \ | |
-H "X-GitHub-Api-Version: 2022-11-28" \ | |
https://api.github.com/repos/$REPO/traffic/clones > clone_stats.json | |
- name: Upload Clone Stats | |
uses: actions/upload-artifact@v4 | |
with: | |
name: clone-stats | |
path: clone_stats.json | |
print-stats: | |
needs: fetch-clone-stats | |
runs-on: ubuntu-latest | |
steps: | |
- name: Check out code | |
uses: actions/checkout@v3 | |
- name: Download Clone Stats | |
uses: actions/download-artifact@v4 | |
with: | |
name: clone-stats | |
path: . | |
- name: Print raw JSON | |
run: cat clone_stats.json | |
- name: Parse and Print Stats | |
id: parse | |
run: | | |
COUNT=$(jq '.count' clone_stats.json) | |
UNIQUES=$(jq '.uniques' clone_stats.json) | |
echo "Total Clones: $COUNT" | |
echo "Unique Cloners: $UNIQUES" |