This repository was archived by the owner on Mar 18, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgithub_scrape.sh
More file actions
40 lines (32 loc) · 1.82 KB
/
github_scrape.sh
File metadata and controls
40 lines (32 loc) · 1.82 KB
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
#!/bin/bash
# Get user
username=$USER
if [ "$username" = root ]; then username=$SUDO_USER; fi
# Get data from github
curl -L -H "Accept: application/vnd.github+json" -H "X-GitHub-Api-Version: 2022-11-28" "https://api.github.com/repos/stfc/SCD-Openstack-Utils/contributors?per_page-100" | grep 'contributions\|login' | paste -d "" - - > ./SCD_Openstack_Utils_commits
# Format data
sed -i 's/"//g' ./SCD_Openstack_Utils_commits
sed -i 's/login: //g' ./SCD_Openstack_Utils_commits
sed -i 's/contributions: //g' ./SCD_Openstack_Utils_commits
sed -i 's/ //g' ./SCD_Openstack_Utils_commits
sed -i 's/,/, /g' ./SCD_Openstack_Utils_commits
# Add to MySql table each line
while read line; do
commiter=$( awk -F', ' '{ print $1 }' <<< $line)
no_commits=$( awk -F', ' '{ print $2 }' <<< $line)
mysql -u"$username" -ppassword -e "INSERT INTO githubstats.scd_openstack_utils_commits (username, no_commits) VALUES ('${commiter}', '${no_commits}');"
done < ./SCD_Openstack_Utils_commits
# Get data from github
curl -L -H "Accept: application/vnd.github+json" -H "X-GitHub-Api-Version: 2022-11-28" "https://api.github.com/repos/stfc/st2-cloud-pack/contributors?per_page-100" | grep 'contributions\|login' | paste -d "" - - > ./st2_cloud_pack_commits
# Format data
sed -i 's/"//g' ./st2_cloud_pack_commit
sed -i 's/login: //g' ./st2_cloud_pack_commits
sed -i 's/contributions: //g' ./st2_cloud_pack_commits
sed -i 's/ //g' ./st2_cloud_pack_commits
sed -i 's/,/, /g' ./st2_cloud_pack_commits
# Add to MySql table each line
while read line; do
commiter=$( awk -F', ' '{ print $1 }' <<< $line)
no_commits=$( awk -F', ' '{ print $2 }' <<< $line)
mysql -u"$username" -ppassword -e "INSERT INTO githubstats.st2_cloud_pack_commits (username, no_commits) VALUES ('${commiter}', '${no_commits}');"
done < ./st2_cloud_pack_commits