Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support extracting logs from job URLs that have ?pr=123 query string #4

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions internal/cli/logs.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"fmt"
"io"
"log"
"net/url"
"os"
"sort"
"strings"
Expand Down Expand Up @@ -380,9 +381,13 @@ func getLogGroupArn(arn string) string {
}

func extractJobID(input string) string {
if strings.HasPrefix(input, "https://") {
// Extract job ID from URL like https://github.com/runs-on/runs-on/actions/runs/12312372848/job/34368864490
parts := strings.Split(input, "/")
url, err := url.Parse(input)
if err == nil && url.Scheme == "https" {
// Extract job ID from URLs like:
//
// - https://github.com/runs-on/runs-on/actions/runs/12312372848/job/34368864490
// - https://github.com/runs-on/runs-on/actions/runs/12312372848/job/34368864490?pr=123
parts := strings.Split(url.Path, "/")
if len(parts) > 1 {
return parts[len(parts)-1]
}
Expand Down