Skip to content

Update Weekly GitHub Stats #8

Update Weekly GitHub Stats

Update Weekly GitHub Stats #8

Workflow file for this run

name: Update Weekly GitHub Stats
on:
workflow_dispatch:
schedule:
# Run every Monday at 00:00 UTC
- cron: '0 0 * * 1'
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.USER_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.USER_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,Unique Clones,Views,Unique Views" > stats.csv
echo "$DATE,$CLONES,$UNIQUECLONES,$VIEWS,$UNIQUEVIEWS"
- 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 }}