Skip to content

Commit

Permalink
Hack to workaround Github API returning an out-of-date badge URL
Browse files Browse the repository at this point in the history
  • Loading branch information
fileformat committed Nov 4, 2024
1 parent 34c568e commit 82e99b9
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions workflows.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package main

import (
"context"
"fmt"
"log/slog"
"strings"

Expand Down Expand Up @@ -36,6 +37,14 @@ func GetWorkflowsForRepo(client *github.Client, repo *github.Repository) ([]*git
continue
}
}

if !strings.Contains(*workflow.BadgeURL, "/actions/workflow") {
var parts = strings.Split(*workflow.Path, "/")
var yaml = parts[len(parts)-1]
var newBadgeUrl = fmt.Sprintf("https://github.com/%s/actions/workflows/%s/badge.svg", *repo.FullName, yaml)
slog.Debug("Hack to fix busted Github API result", "repo", *repo.FullName, "badbadge", *workflow.BadgeURL, "goodbadge", newBadgeUrl)
*workflow.BadgeURL = newBadgeUrl
}
allWorkflows = append(allWorkflows, workflow)
}
if resp.NextPage == 0 {
Expand Down

0 comments on commit 82e99b9

Please sign in to comment.