Skip to content
Merged
Show file tree
Hide file tree
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
18 changes: 18 additions & 0 deletions pkg/gh/label.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package gh

import "strings"

// IsRequestedMyshoesLabel checks if the job has appropriate labels for myshoes
func IsRequestedMyshoesLabel(labels []string) bool {
// Accept dependabot runner in GHES
if len(labels) == 1 && strings.EqualFold(labels[0], "dependabot") {
return true
}

for _, label := range labels {
if strings.EqualFold(label, "myshoes") || strings.EqualFold(label, "self-hosted") {
return true
}
}
return false
}
6 changes: 2 additions & 4 deletions pkg/starter/scripts.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ func (s *Starter) getSetupScript(ctx context.Context, targetScope, runnerName st

func (s *Starter) getSetupRawScript(ctx context.Context, targetScope, runnerName string) (string, error) {
runnerUser := config.Config.RunnerUser
githubURL := config.Config.GitHubURL

targetRunnerVersion := s.runnerVersion
if strings.EqualFold(s.runnerVersion, "latest") {
Expand Down Expand Up @@ -77,9 +76,8 @@ func (s *Starter) getSetupRawScript(ctx context.Context, targetScope, runnerName
}

var labels []string
Copy link

Copilot AI Jul 24, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The unconditional addition of the 'dependabot' label may cause confusion. Consider adding a comment explaining why this label is always added, especially since the original conditional logic based on GitHub URL was removed.

Suggested change
var labels []string
var labels []string
// The "dependabot" label is always added to ensure compatibility with Dependabot-related workflows.

Copilot uses AI. Check for mistakes.
if githubURL != "" && githubURL != "https://github.com" {
labels = append(labels, "dependabot")
}
// The "dependabot" label is always added to ensure compatibility with Dependabot-related workflows.
labels = append(labels, "dependabot")

v := templateCreateLatestRunnerOnceValue{
Scope: targetScope,
Expand Down
7 changes: 7 additions & 0 deletions pkg/starter/starter.go
Original file line number Diff line number Diff line change
Expand Up @@ -483,6 +483,13 @@ func enqueueRescueRun(ctx context.Context, pendingRun datastore.PendingWorkflowR
continue
}

// Check if the job has appropriate labels for myshoes
if !gh.IsRequestedMyshoesLabel(job.Labels) {
logger.Logf(true, "skip rescue job because it doesn't have myshoes labels: (repo: %s, gh_run_id: %d, gh_job_id: %d, labels: %v)",
fullName, pendingRun.WorkflowRun.GetID(), job.GetID(), job.Labels)
continue
}

// Get installation ID from target scope
installationID, err := gh.IsInstalledGitHubApp(ctx, target.Scope)
if err != nil {
Expand Down
15 changes: 1 addition & 14 deletions pkg/web/webhook.go
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ func receiveWorkflowJobWebhook(ctx context.Context, event *github.WorkflowJobEve
repoURL := repo.GetHTMLURL()

labels := event.GetWorkflowJob().Labels
if !isRequestedMyshoesLabel(labels) {
if !gh.IsRequestedMyshoesLabel(labels) {
// is not request myshoes, So will be ignored
logger.Logf(true, "label \"myshoes\" is not found in labels, so ignore (labels: %s)", labels)
return nil
Expand All @@ -221,16 +221,3 @@ func receiveWorkflowJobWebhook(ctx context.Context, event *github.WorkflowJobEve
return nil
}

func isRequestedMyshoesLabel(labels []string) bool {
// Accept dependabot runner in GHES
if len(labels) == 1 && strings.EqualFold(labels[0], "dependabot") {
return true
}

for _, label := range labels {
if strings.EqualFold(label, "myshoes") || strings.EqualFold(label, "self-hosted") {
return true
}
}
return false
}