From f382591ef11c8f0eba0850cefdd0c1a5c421d06a Mon Sep 17 00:00:00 2001 From: GitCaddy Date: Sun, 11 Jan 2026 22:53:18 +0000 Subject: [PATCH] feat: use SuggestedLabels from runner capabilities MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Add StringUtils.HasSuffix template function - Update runner edit template to use SuggestedLabels from capabilities - Auto-suggest -latest variants for OS-type labels (ios, macos, xcode, etc.) - Falls back to OS-based suggestions if no SuggestedLabels available 🤖 Generated with Claude Code Co-Authored-By: Claude Opus 4.5 --- modules/templates/util_string.go | 1 + templates/shared/actions/runner_edit.tmpl | 63 ++++++++++++----------- 2 files changed, 33 insertions(+), 31 deletions(-) diff --git a/modules/templates/util_string.go b/modules/templates/util_string.go index bd2ddba278..2b3e0106da 100644 --- a/modules/templates/util_string.go +++ b/modules/templates/util_string.go @@ -35,6 +35,7 @@ func (su *StringUtils) ToString(v any) string { func (su *StringUtils) HasPrefix(s, prefix string) bool { return strings.HasPrefix(s, prefix) } +func (su *StringUtils) HasSuffix(s, suffix string) bool { return strings.HasSuffix(s, suffix)} func (su *StringUtils) Contains(s, substr string) bool { return strings.Contains(s, substr) diff --git a/templates/shared/actions/runner_edit.tmpl b/templates/shared/actions/runner_edit.tmpl index 61e57f617e..e6cee5597d 100644 --- a/templates/shared/actions/runner_edit.tmpl +++ b/templates/shared/actions/runner_edit.tmpl @@ -100,37 +100,38 @@

Based on detected capabilities. Click + to add individually.

{{$labels := .Runner.AgentLabels}} - {{if eq .RunnerCapabilities.OS "linux"}} - {{if not (SliceUtils.Contains $labels "linux")}} -
{{$.CsrfTokenHtml}}
- {{else}}linux{{end}} - {{if not (SliceUtils.Contains $labels "linux-latest")}} -
{{$.CsrfTokenHtml}}
- {{else}}linux-latest{{end}} - {{else if eq .RunnerCapabilities.OS "windows"}} - {{if not (SliceUtils.Contains $labels "windows")}} -
{{$.CsrfTokenHtml}}
- {{else}}windows{{end}} - {{if not (SliceUtils.Contains $labels "windows-latest")}} -
{{$.CsrfTokenHtml}}
- {{else}}windows-latest{{end}} - {{else if eq .RunnerCapabilities.OS "darwin"}} - {{if not (SliceUtils.Contains $labels "macos")}} -
{{$.CsrfTokenHtml}}
- {{else}}macos{{end}} - {{if not (SliceUtils.Contains $labels "macos-latest")}} -
{{$.CsrfTokenHtml}}
- {{else}}macos-latest{{end}} - {{end}} - {{if and .RunnerCapabilities.Distro .RunnerCapabilities.Distro.ID}} - {{$distro := .RunnerCapabilities.Distro.ID}} - {{$distroLatest := printf "%s-latest" .RunnerCapabilities.Distro.ID}} - {{if not (SliceUtils.Contains $labels $distro)}} -
{{$.CsrfTokenHtml}}
- {{else}}{{$distro}}{{end}} - {{if not (SliceUtils.Contains $labels $distroLatest)}} -
{{$.CsrfTokenHtml}}
- {{else}}{{$distroLatest}}{{end}} + {{if .RunnerCapabilities.SuggestedLabels}} + {{range .RunnerCapabilities.SuggestedLabels}} + {{$label := .}} + {{$latestLabel := printf "%s-latest" .}} + {{if not (SliceUtils.Contains $labels $label)}} +
+ {{$.CsrfTokenHtml}} + +
+ {{else}}{{$label}}{{end}} + {{/* Auto-suggest -latest variant for OS-type labels */}} + {{if and (not (StringUtils.HasSuffix $label "-latest")) (not (SliceUtils.Contains $labels $latestLabel))}} + {{if or (eq $label "linux") (eq $label "macos") (eq $label "windows") (eq $label "ios") (eq $label "xcode") (eq $label "tvos") (eq $label "watchos") (eq $label "visionos") (eq $label "debian") (eq $label "ubuntu") (eq $label "fedora") (eq $label "dotnet") (eq $label "node")}} +
+ {{$.CsrfTokenHtml}} + +
+ {{end}} + {{end}} + {{end}} + {{else}} + {{/* Fallback to OS-based suggestions if no SuggestedLabels */}} + {{if eq .RunnerCapabilities.OS "linux"}} + {{if not (SliceUtils.Contains $labels "linux")}}
{{$.CsrfTokenHtml}}
{{else}}linux{{end}} + {{if not (SliceUtils.Contains $labels "linux-latest")}}
{{$.CsrfTokenHtml}}
{{else}}linux-latest{{end}} + {{else if eq .RunnerCapabilities.OS "windows"}} + {{if not (SliceUtils.Contains $labels "windows")}}
{{$.CsrfTokenHtml}}
{{else}}windows{{end}} + {{if not (SliceUtils.Contains $labels "windows-latest")}}
{{$.CsrfTokenHtml}}
{{else}}windows-latest{{end}} + {{else if eq .RunnerCapabilities.OS "darwin"}} + {{if not (SliceUtils.Contains $labels "macos")}}
{{$.CsrfTokenHtml}}
{{else}}macos{{end}} + {{if not (SliceUtils.Contains $labels "macos-latest")}}
{{$.CsrfTokenHtml}}
{{else}}macos-latest{{end}} + {{end}} {{end}}