Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GH actions for traffic monitoring #4

Open
wants to merge 63 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
63 commits
Select commit Hold shift + click to select a range
75c79e3
GH traffic workflow
korbinib Dec 16, 2024
4cfbd6a
Update GH_traffic.yml
korbinib Dec 16, 2024
2aeb62b
Update GH_traffic.yml
korbinib Dec 16, 2024
f21bba2
Update GH_traffic.yml
korbinib Dec 16, 2024
c082734
zenodo stats
korbinib Dec 16, 2024
425d160
Merge branch 'traffic' of github.com:korbinib/NMRLipids.github.io int…
korbinib Dec 16, 2024
a1b6223
Merge pull request #1 from korbinib/traffic
korbinib Dec 16, 2024
71aeba7
Update GH_traffic.yml
korbinib Dec 16, 2024
249edde
Update zenodo_stats.yml
korbinib Dec 16, 2024
7730b3a
Update zenodo_stats.yml
korbinib Dec 16, 2024
0beea97
Update zenodo_stats.yml
korbinib Dec 16, 2024
4c08df1
Update zenodo_stats.sh
korbinib Dec 16, 2024
98cfea6
Update zenodo_stats.sh
korbinib Dec 16, 2024
d4ea53e
Update zenodo_stats.yml
korbinib Dec 16, 2024
60e5a20
mv to .scripts
korbinib Dec 16, 2024
097f702
perm .scripts
korbinib Dec 16, 2024
a32474d
Update zenodo_stats.sh
korbinib Dec 16, 2024
fcc95fa
Update zenodo_stats.sh
korbinib Dec 16, 2024
cb06a8e
Update zenodo_stats.sh
korbinib Dec 16, 2024
0d97a20
Update zenodo_stats.yml
korbinib Dec 16, 2024
cee4fa0
Update zenodo_stats.yml
korbinib Dec 16, 2024
664a912
Update zenodo_stats.yml
korbinib Dec 16, 2024
b1201ae
Update zenodo_stats.yml
korbinib Dec 16, 2024
a0ab913
Zenodo stats
korbinib Dec 16, 2024
4ba687c
Zenodo stats
korbinib Dec 16, 2024
06db294
Zenodo stats
korbinib Dec 17, 2024
d938aaa
GitHub traffic
korbinib Dec 17, 2024
8a44ff9
folder structure
korbinib Dec 18, 2024
05ef1fd
GitHub traffic
korbinib Dec 19, 2024
65e7558
GitHub traffic
korbinib Dec 20, 2024
e83d1fe
GitHub traffic
korbinib Dec 21, 2024
8b7ad0e
GitHub traffic
korbinib Dec 22, 2024
3145f80
GitHub traffic
korbinib Dec 23, 2024
9078848
GitHub traffic
korbinib Dec 24, 2024
bd445ec
GitHub traffic
korbinib Dec 25, 2024
876e497
GitHub traffic
korbinib Dec 26, 2024
2f048e3
GitHub traffic
korbinib Dec 27, 2024
c163d07
GitHub traffic
korbinib Dec 28, 2024
eff1431
GitHub traffic
korbinib Dec 29, 2024
21c54dc
GitHub traffic
korbinib Dec 30, 2024
391fdf7
GitHub traffic
korbinib Dec 31, 2024
50fa7af
GitHub traffic
korbinib Jan 1, 2025
8b9987f
GitHub traffic
korbinib Jan 2, 2025
2f42eca
GitHub traffic
korbinib Jan 3, 2025
b629898
GitHub traffic
korbinib Jan 4, 2025
7cef6dd
GitHub traffic
korbinib Jan 5, 2025
cc57c24
GitHub traffic
korbinib Jan 6, 2025
0f792c0
GitHub traffic
korbinib Jan 7, 2025
7fc9a0b
GitHub traffic
korbinib Jan 8, 2025
e2fca9a
GitHub traffic
korbinib Jan 9, 2025
c504226
GitHub traffic
korbinib Jan 10, 2025
ac8f5b8
GitHub traffic
korbinib Jan 11, 2025
b2f87e6
GitHub traffic
korbinib Jan 12, 2025
3dfcb57
Update zenodo_stats.yml
korbinib Jan 13, 2025
c37cb72
Zenodo stats
korbinib Jan 13, 2025
be50693
Zenodo stats
korbinib Jan 14, 2025
57e3642
GitHub traffic
korbinib Jan 14, 2025
9424879
Zenodo stats
korbinib Jan 15, 2025
0484606
GitHub traffic
korbinib Jan 15, 2025
5113818
Zenodo stats
korbinib Jan 16, 2025
262bc44
GitHub traffic
korbinib Jan 16, 2025
6c9c0bd
Zenodo stats
korbinib Jan 17, 2025
7a25500
GitHub traffic
korbinib Jan 17, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 31 additions & 0 deletions .github/workflows/GH_traffic.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
on:
workflow_dispatch:
schedule:
# runs once a day
- cron: "55 23 * * *"

jobs:
# This workflow contains a single job called "traffic"
traffic:
# The type of runner that the job will run on
runs-on: ubuntu-latest

# Steps represent a sequence of tasks that will be executed as part of the job
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v2

# Calculates traffic and clones and stores in CSV file
- name: GitHub traffic
uses: sangonzal/[email protected]
env:
TRAFFIC_ACTION_TOKEN: ${{ secrets.TRAFFIC_ACTION_TOKEN }}
REPOSITORY_NAME: "NMRLipids/Databank"

# Commits files to repository
- name: Commit changes
uses: EndBug/add-and-commit@v4
with:
author_name: GitHub action
message: "GitHub traffic"
add: "./traffic/*"
38 changes: 38 additions & 0 deletions .github/workflows/zenodo_stats.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
on:
workflow_dispatch:
schedule:
# runs once a day
- cron: "05 22 * * *"

jobs:
zenodo_stats:
# The type of runner that the job will run on
runs-on: ubuntu-latest
defaults:
run:
working-directory: .

# Steps represent a sequence of tasks that will be executed as part of the job

steps:
- name: Check out repo
uses: actions/checkout@v4

- name: Check out NMRLipids/Databank
uses: actions/checkout@v4
with:
repository: NMRLipids/Databank
path: NMRLipidsDB

# Get zenodo DOIs and query stats from API
- name: Zenodo stats
run: |
.scripts/zenodo_stats.sh

# Commits files to repository
- name: Commit changes
uses: EndBug/add-and-commit@v4
with:
author_name: GitHub action
message: "Zenodo stats"
add: 'traffic/zenodo_stats.csv'
64 changes: 64 additions & 0 deletions .scripts/zenodo_stats.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
#!/bin/bash

# Output file for DOIs
doi_output_file="zenodo_dois.txt"

# Clear output file
> "$doi_output_file"

# Current date
date=$(date --iso-8601)


# Find all README.yml files and extract the zenodo DOI key
find NMRLipidsDB -name "README.yaml" | while read -r file; do
echo "Processing $file"

doi=$(grep -o 'DOI: .*10.5281/zenodo.*' "$file" | awk '{print $2}')
if [ -n "$doi" ]; then
echo "DOI found: $doi"
echo "$doi" >> "$doi_output_file"
else
echo "No DOI found in $file"
fi
done

mkdir -p traffic
stats_output_file="traffic/zenodo_stats.csv"

if [ ! -f "$stats_output_file" ]; then
echo "doi,date,downloads,unique_downloads,views,unique_views,version_downloads,version_unique_downloads,version_views,version_unique_views" > "$stats_output_file"
fi

mapfile -t dois_array < zenodo_dois.txt

for doi in "${dois_array[@]}"; do
# remove the base DOI part
identifier=$(echo "$doi" | sed 's/10\.5281\/zenodo\.//')
#echo "DOI $doi"
#echo "ID $identifier"

# Fetch JSON data
response=$(curl -s "https://zenodo.org/api/records/$identifier")

# Check if successful
if [[ $? -eq 0 ]]; then
#echo "URL https://zenodo.org/api/records/$identifier"
#echo "RESPONSE: $response"

downloads=$(echo "$response" | jq '.stats.downloads')
unique_downloads=$(echo "$response" | jq '.stats.unique_downloads')
views=$(echo "$response" | jq '.stats.views')
unique_views=$(echo "$response" | jq '.stats.unique_views')
version_downloads=$(echo "$response" | jq '.stats.version_downloads')
version_unique_downloads=$(echo "$response" | jq '.stats.version_unique_downloads')
version_views=$(echo "$response" | jq '.stats.version_views')
version_unique_views=$(echo "$response" | jq '.stats.version_unique_views')

# Write the extracted data to CSV
#echo "Got stats for $doi"
echo "$doi,$date,$downloads,$unique_downloads,$views,$unique_views,$version_downloads,$version_unique_downloads,$version_views,$version_unique_views" >> "$stats_output_file"
else
echo "Failed to fetch data for DOI: $doi"
fi
done
35 changes: 35 additions & 0 deletions traffic/clones.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
_date,total_clones,unique_clones
2024-12-09,1,1
2024-12-16,15,2
2024-12-17,3,1
2024-12-18,3,2
2024-12-19,1,1
2024-12-20,1,1
2024-12-21,2,2
2024-12-22,1,1
2024-12-23,1,1
2024-12-24,1,1
2024-12-25,1,1
2024-12-26,1,1
2024-12-27,1,1
2024-12-28,1,1
2024-12-29,1,1
2024-12-30,1,1
2024-12-31,1,1
2025-01-01,1,1
2025-01-02,1,1
2025-01-03,1,1
2025-01-04,1,1
2025-01-05,1,1
2025-01-06,2,2
2025-01-07,2,1
2025-01-08,1,1
2025-01-09,1,1
2025-01-10,1,1
2025-01-11,1,1
2025-01-12,1,1
2025-01-13,2,2
2025-01-14,1,1
2025-01-15,1,1
2025-01-16,1,1
2025-01-17,1,1
Binary file added traffic/plots.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
39 changes: 39 additions & 0 deletions traffic/views.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
_date,total_views,unique_views
2024-12-04,25,8
2024-12-05,10,3
2024-12-06,2,1
2024-12-07,26,4
2024-12-08,8,2
2024-12-09,68,7
2024-12-10,28,4
2024-12-11,43,5
2024-12-12,14,6
2024-12-13,43,6
2024-12-14,3,1
2024-12-15,5,1
2024-12-16,47,5
2024-12-17,59,6
2024-12-18,8,1
2024-12-19,9,3
2024-12-20,49,5
2024-12-22,21,2
2024-12-23,5,2
2024-12-25,1,1
2024-12-26,10,3
2024-12-27,1,1
2024-12-28,12,1
2025-01-01,1,1
2025-01-02,48,4
2025-01-03,5,3
2025-01-04,1,1
2025-01-06,8,5
2025-01-07,15,3
2025-01-08,1,1
2025-01-10,31,3
2025-01-11,29,3
2025-01-12,40,4
2025-01-13,2,1
2025-01-14,3,2
2025-01-15,1,1
2025-01-16,31,4
2025-01-17,44,3
Loading