dot dot dotfiles
at main 52 lines 1.8 kB view raw
1#!/usr/bin/bash 2 3REPODIR=/<path>/<to>/repos/ 4BASEURL='https://github.com/' 5 6NC='\033[0m' 7ARG='\033[0;31m' # red 8TXT='\033[0;32m' # green, or 1;32m for light green 9SYM='\u2192' # right arrow 10 11# local directories to exclude 12EXCLUDE=( 13 "${REPODIR}mpadge/gender-ai/" 14 "${REPODIR}pre-processing-r/rpp/" 15 "${REPODIR}ropensci/dev_guide/" 16 "${REPODIR}ropensci-org/pkgreviewr/" 17 "${REPODIR}ropensci-review-tools/tree-sitter-diff/tests/csitter/tree-sitter/" 18 "${REPODIR}ropensci/roweb3/" 19 "${REPODIR}ropensci-stats/badges/" 20 "${REPODIR}rosadmin/annual-reporting/" 21) 22 23grepCronJobs() { 24 rg "\\-\\scron\\:" --hidden ${REPODIR} | cut -d: -f1 | awk '/\.github\// { 25 split($0, parts, ".github/") 26 print parts[1] 27 }' | sort -u | grep -v -f <(printf "%s\n" "${EXCLUDE[@]}") 28} 29 30if [ "$1" == "" ] || [ "$1" == "help" ]; then 31 echo -e "${TXT}Script to list or open pages of all repositories${NC}" 32 echo -e "${TXT}containing cron jobs run on GitHub actions.${NC}" 33 echo -e "" 34 echo -e "${SYM} ${ARG}grep/list${NC} : ${TXT}Grep all repos with cron workflows${NC}" 35 echo -e "${SYM} ${ARG}open${NC} : ${TXT}Open GitHub pages of all cron workflows${NC}" 36 echo -e "${SYM} ${ARG}help (default)${NC} : ${TXT}Display these help messages${NC}" 37elif [ "$1" == "grep" ] || [ "$1" == "list" ]; then 38 echo -e "${TXT}The following directories have GitHub actions cron jobs:${NC}" 39 echo -e "" 40 grepCronJobs | while read -r line; do 41 url="${line/$REPODIR/$BASEURL}" 42 echo -e "${TXT}${line}${NC} ${SYM} ${ARG}${url}" 43 done 44elif [ "$1" == "open" ]; then 45 grepCronJobs | sed 's|$|actions|' | while read -r line; do 46 url="${line/$REPODIR/$BASEURL}" 47 echo -e "${TXT}${line}${NC}" 48 xdg-open "$url" 49 done 50else 51 echo "Unknown option" 52fi