Skip to content

Commit 51151a9

Browse files
committed
fix: cache workflow
1 parent 0493b4b commit 51151a9

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

pkg/metrics/get_workflow_runs_from_github.go

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,16 @@ func getFieldValue(repo string, run github.WorkflowRun, field string) string {
2929
case "workflow_id":
3030
return strconv.FormatInt(*run.WorkflowID, 10)
3131
case "workflow":
32-
return *workflows[repo][*run.WorkflowID].Name
32+
if workflows != nil && workflows[repo] != nil {
33+
w, exist := workflows[repo][*run.WorkflowID]
34+
if !exist {
35+
log.Printf("Couldn't fetch repo '%s', workflow '%d' from workflow cache.", repo, *run.WorkflowID)
36+
return "unknown"
37+
}
38+
39+
return *w.Name
40+
}
41+
return ""
3342
case "event":
3443
return *run.Event
3544
case "status":

0 commit comments

Comments
 (0)