Last active
May 22, 2023 00:53
-
-
Save eginez/461e6ccaf6f14fd982aee1eff8e94362 to your computer and use it in GitHub Desktop.
Github workflow logs in the command line
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function gh_logs() { | |
#needs fzf, jq, github cli | |
branch_name=${1:-} | |
repo_name= | |
if [[ -n $2 ]]; then | |
repo_name="-R$2" | |
fi | |
job_name=$(gh $repo_name pr checks $branch_name|fzf|cut -d$'\t' -f1) | |
run_id=$(gh $repo_name pr checks $branch_name|grep "$job_name"|cut -d'/' -f8) | |
echo run id: $run_id | |
job_id=$(gh $repo_name run view $run_id --json jobs|jq --arg f "$job_name" '.jobs|.[]|{name, databaseId}|select(.name == $f)|.databaseId') | |
echo job id: $job_id | |
gh $repo_name run view --log --job=$job_id | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment