Skip to content
This repository was archived by the owner on May 3, 2025. It is now read-only.

Commit ddad47a

Browse files
committed
ci: Add script to view latest failed workflow logs
This commit adds a bash script named `get-latest-failed-gha-logs.sh` that automates the retrieval and display of failed GitHub Actions workflow logs. The script uses `gh` CLI commands to: - Fetch the latest workflow run ID. - Determine the run's conclusion (success or failure). - If the run failed, display the failed logs using `gh run view --log-failed`.
1 parent 070117a commit ddad47a

1 file changed

Lines changed: 15 additions & 0 deletions

File tree

get-latest-failed-gha-logs.sh

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#!/bin/bash
2+
3+
# Get the latest workflow run ID
4+
run_id=$(gh run list -L 1 | awk '{print $1}')
5+
6+
# Get the run conclusion (e.g., "success", "failure")
7+
conclusion=$(gh run view $run_id --json conclusion | jq -r '.conclusion')
8+
9+
# Check if the run failed
10+
if [[ "$conclusion" == "failure" ]]; then
11+
# View the failed logs
12+
gh run view $run_id --log-failed
13+
else
14+
echo "The latest workflow run was successful."
15+
fi

0 commit comments

Comments
 (0)