diff --git a/pkg/runner/run_context.go b/pkg/runner/run_context.go index e24a236..dd082fd 100644 --- a/pkg/runner/run_context.go +++ b/pkg/runner/run_context.go @@ -567,6 +567,7 @@ func (rc *RunContext) getGithubContext(ctx context.Context) *model.GithubContext EventName: rc.Config.EventName, Action: rc.CurrentStep, Token: rc.Config.Token, + Job: rc.Run.JobID, ActionPath: rc.ActionPath, RepositoryOwner: rc.Config.Env["GITHUB_REPOSITORY_OWNER"], RetentionDays: rc.Config.Env["GITHUB_RETENTION_DAYS"], @@ -693,7 +694,7 @@ func (rc *RunContext) withGithubEnv(ctx context.Context, github *model.GithubCon env["GITHUB_REF_NAME"] = github.RefName env["GITHUB_REF_TYPE"] = github.RefType env["GITHUB_TOKEN"] = github.Token - env["GITHUB_JOB"] = rc.JobName + env["GITHUB_JOB"] = github.Job env["GITHUB_REPOSITORY_OWNER"] = github.RepositoryOwner env["GITHUB_RETENTION_DAYS"] = github.RetentionDays env["RUNNER_PERFLOG"] = github.RunnerPerflog diff --git a/pkg/runner/run_context_test.go b/pkg/runner/run_context_test.go index de8f177..e705946 100644 --- a/pkg/runner/run_context_test.go +++ b/pkg/runner/run_context_test.go @@ -144,6 +144,7 @@ func TestRunContext_EvalBool(t *testing.T) { // Check github context {in: "github.actor == 'nektos/act'", out: true}, {in: "github.actor == 'unknown'", out: false}, + {in: "github.job == 'job1'", out: true}, // The special ACT flag {in: "${{ env.ACT }}", out: true}, {in: "${{ !env.ACT }}", out: false}, @@ -364,6 +365,7 @@ func TestGetGitHubContext(t *testing.T) { StepResults: map[string]*model.StepResult{}, OutputMappings: map[MappableOutput]MappableOutput{}, } + rc.Run.JobID = "job1" ghc := rc.getGithubContext(context.Background()) @@ -392,6 +394,7 @@ func TestGetGitHubContext(t *testing.T) { assert.Equal(t, ghc.RepositoryOwner, owner) assert.Equal(t, ghc.RunnerPerflog, "/dev/null") assert.Equal(t, ghc.Token, rc.Config.Secrets["GITHUB_TOKEN"]) + assert.Equal(t, ghc.Job, "job1") } func TestGetGithubContextRef(t *testing.T) { diff --git a/pkg/runner/step_test.go b/pkg/runner/step_test.go index 86e5acc..4fc7765 100644 --- a/pkg/runner/step_test.go +++ b/pkg/runner/step_test.go @@ -175,7 +175,7 @@ func TestSetupEnv(t *testing.T) { "GITHUB_EVENT_PATH": "/var/run/act/workflow/event.json", "GITHUB_GRAPHQL_URL": "https:///api/graphql", "GITHUB_HEAD_REF": "", - "GITHUB_JOB": "", + "GITHUB_JOB": "1", "GITHUB_RETENTION_DAYS": "0", "GITHUB_RUN_ID": "runId", "GITHUB_RUN_NUMBER": "1",