-
Notifications
You must be signed in to change notification settings - Fork 1
/
generate-badges.go
52 lines (44 loc) · 1.05 KB
/
generate-badges.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
package main
import (
"fmt"
"log"
"os"
"strings"
)
func main() {
entries, err := os.ReadDir(".github/workflows")
if err != nil {
log.Fatal(err)
}
badges := []string{}
links := []string{}
for i := range entries {
entry := entries[i]
name := entry.Name()
if strings.HasPrefix(name, "build-") && !strings.HasPrefix(name, "build-and-cache") {
name, _ = strings.CutPrefix(name, "build-")
name, _ = strings.CutSuffix(name, ".yml")
badges = append(badges, fmt.Sprintf(`![[%s][%s]][%s-svg]`, name, name, name))
links = append(
links,
fmt.Sprintf(
`[%s]: https://github.com/northwood-labs/package-building/actions/workflows/build-%s.yml`,
name,
name,
),
)
links = append(
links,
fmt.Sprintf(
`[%s-svg]: https://img.shields.io/github/actions/workflow/status/northwood-labs/package-building/build-%s.yml?style=flat-square&label=%s&labelColor=171e21`,
name,
name,
name,
),
)
}
}
fmt.Println(strings.Join(badges, "\n"))
fmt.Println("")
fmt.Println(strings.Join(links, "\n"))
}