From 00fbfa754c95fb3af85e547364d4f6512c15f5ff Mon Sep 17 00:00:00 2001
From: Jon Jensen <jenseng@gmail.com>
Date: Sat, 16 Dec 2023 15:04:54 -0800
Subject: [PATCH] Fix noisy `runs-on` error logging (#2102)

Move the logging back up a level to fix a minor logging issue introduced in #2088

`RunContext`s for composite actions have dummy/blank `Job`s with no `runs-on`,
meaning their calls to `withGithubEnv` would result in an inaccurate log message
complaining that `'runs-on' key not defined in ...`

Co-authored-by: Jason Song <i@wolfogre.com>
Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
---
 pkg/runner/run_context.go | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/pkg/runner/run_context.go b/pkg/runner/run_context.go
index 5afa6f7..937b480 100644
--- a/pkg/runner/run_context.go
+++ b/pkg/runner/run_context.go
@@ -635,6 +635,10 @@ func (rc *RunContext) containerImage(ctx context.Context) string {
 }
 
 func (rc *RunContext) runsOnImage(ctx context.Context) string {
+	if rc.Run.Job().RunsOn() == nil {
+		common.Logger(ctx).Errorf("'runs-on' key not defined in %s", rc.String())
+	}
+
 	for _, platformName := range rc.runsOnPlatformNames(ctx) {
 		image := rc.Config.Platforms[strings.ToLower(platformName)]
 		if image != "" {
@@ -649,7 +653,6 @@ func (rc *RunContext) runsOnPlatformNames(ctx context.Context) []string {
 	job := rc.Run.Job()
 
 	if job.RunsOn() == nil {
-		common.Logger(ctx).Errorf("'runs-on' key not defined in %s", rc.String())
 		return []string{}
 	}