Skip to content

Commit

Permalink
feat(run): ask to rerun after dunstify's log action
Browse files Browse the repository at this point in the history
Ask the user if they want to rerun the workflow after viewing the logs
via the notification action. The prompt is only displayed if:

- The run failed
- The notification was created by `dunstify`
- One of the following is installed (tried in order): `rofi` or `dmenu`

The prompt is displayed after closing the logs.
  • Loading branch information
benelan committed Jun 1, 2024
1 parent b419d35 commit ff14747
Showing 1 changed file with 22 additions and 3 deletions.
25 changes: 22 additions & 3 deletions gh-fzf
Original file line number Diff line number Diff line change
Expand Up @@ -682,22 +682,41 @@ notify_run_completed() {
download) gh run download $run_id $repo_flag ;;
rerun)
gh run rerun --failed $run_id $repo_flag
gh fzf util notify-run-completed $run_id $repo_flag
gh fzf util notify-run-completed $run_id $repo_flag &
;;
log)
case $TERMINAL in
x-terminal-emulator | xterm | wezterm | kitty | alacritty | \
gnome-terminal | konsole | foot | eterm | st)
$TERMINAL -e sh -c "gh run view --log $run_id $repo_flag" &
$TERMINAL -e sh -c "gh run view --log $run_id $repo_flag"
;;
*)
tmpfile="$(
mktemp gh-fzf-run-${run_id}_XXX --tmpdir --suffix .log
)"
gh run view --log $run_id $repo_flag >"$tmpfile"
xdg-open "$tmpfile" &
xdg-open "$tmpfile"
;;
esac

if [ -n "$urgency" ]; then
if has rofi; then
rerun_response="$(
printf "%s\n%s" "yes" "no" | rofi -dmenu -l 2 -i -p \
"Rerun${workflow:+ \"$workflow\"}${branch:+ on \"$branch\" branch}?"
)"
elif has dmenu; then
rerun_response="$(
printf "%s\n%s" "yes" "no" | dmenu -i -p \
"Rerun${workflow:+ \"$workflow\"}${branch:+ on \"$branch\" branch}?"
)"
fi

if [ "$rerun_response" = "yes" ]; then
gh run rerun --failed $run_id $repo_flag
gh fzf util notify-run-completed $run_id $repo_flag &
fi
fi
;;
esac
elif has notify-send; then
Expand Down

0 comments on commit ff14747

Please sign in to comment.