From acfd0026cafac65af8449dc8aa0c07ebc6e22ce9 Mon Sep 17 00:00:00 2001 From: "Morgan (hi/him)" Date: Fri, 26 Jan 2024 14:14:01 +0000 Subject: [PATCH] a script to fetch a list of repos and sort them by last activity. --- check_active_repos.sh | 50 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 check_active_repos.sh diff --git a/check_active_repos.sh b/check_active_repos.sh new file mode 100644 index 0000000..ba0d282 --- /dev/null +++ b/check_active_repos.sh @@ -0,0 +1,50 @@ +#!/bin/bash + +# List of GitHub repositories +repos=( + "atas/ssg" + "cfenollosa/bashblog" + "venthur/blag" + "spekulatius/laravel-commonmark-blog" + "imfunniee/gitfolio" + "dannyvankooten/gozer" + "hexojs/hexo" + "hyde/hyde" + "styxlab/next-cms-ghost" + "jekyll/jekyll" + "kabukky/journey" + "sunainapai/makesite" + "imathis/octopress" + "getpelican/pelican" + "williamd1k0/sake" + "spress/Spress" + "nakkaya/static" + "vladris/tinkerer" + "leonstafford" +) + +# Function to get the last commit date +get_last_commit_date() { + curl -s "https://api.github.com/repos/$1/commits" | jq -r '.[0].commit.author.date // empty' +} + +# Check and collect activity data +activity_data=() +for repo in "${repos[@]}"; do + last_commit_date=$(get_last_commit_date "$repo") + if [[ ! -z "$last_commit_date" ]]; then + activity_data+=("$repo: $last_commit_date") + else + activity_data+=("$repo: No recent activity or inaccessible") + fi +done + +# Sort and print the activity data +IFS=$'\n' sorted_activity_data=($(sort -t: -k2 <<<"${activity_data[*]}")) +unset IFS + +echo "Repository activity (sorted by date):" +for data in "${sorted_activity_data[@]}"; do + echo "$data" +done +