-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathgh-run-logview-snazy
executable file
·40 lines (35 loc) · 1.13 KB
/
gh-run-logview-snazy
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
#!/usr/bin/env bash
# Copyright 2022 Chmouel Boudjnah <[email protected]>
#
# Ask for a Github actions run on the current repo with fzf, remove the extra
# prefix suff gh add and pipe it to snazy with some pattern to highlight and bat
# for pager.
#
# you can add a -a to get the whole logs not just the failed
#
# tools: gh, fzf, gnu sed, snazy, bat
#
LIMIT=10
set -eufo pipefail
flags=(--log-failed)
while getopts "al:" o; do
case "${o}" in
a)
flags=(--log)
;;
l)
LIMIT=${OPTARG}
;;
*)
echo "Invalid option"; exit 1;
;;
esac
done
shift $((OPTIND-1))
chosen=$(env GH_FORCE_TTY=80% CLICOLOR_FORCE=1 gh run list --limit ${LIMIT}|fzf --ansi --header-lines=1 --reverse)
[[ -z ${chosen} ]] && { echo "no run is no news is good news"; exit 1 ;}
runnumber=$(echo $chosen|awk '{print $(NF-2)}')
gh run view ${flags[@]} ${runnumber} | \
sed --regexp-extended 's/.*[ ]*[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}\.[0-9]{7}Z//' | \
snazy --color=always -r "RUN:\s*\w+" -r "PASS:\s*\w+" -r "FAIL(:\s+\w+)?" -r "CONT\s*\w+" | \
bat -f