fix: scope the action identity to the step executing an action (#1359)

`github.action_repository`/`github.action_ref` and their env vars now belong to the step executing an action, like on GitHub: set for remote actions, empty for `run`, `docker://` and local steps. Before, a local action nested in a remote composite resolved `$/` against the remote action instead of the workflow's repository.

Updates actionslib to v1.5.1, which accepts `$/` as the repository root action.

Co-authored-by: bircni <[email protected]>
Reviewed-on: https://gitea.com/gitea/runner/pulls/1359
Reviewed-by: bircni <[email protected]>
Co-authored-by: silverwind <[email protected]>
This commit is contained in:
silverwindandbircni authored and silverwind committed 2026-10-29 17:41:27 +00:00
1 parent 5fd2f82735
commit d8d4a4657d
17 files changed
+112 -62

No files matched your search

+17 -3
View File
@@ -27,12 +27,24 @@ type step interface {
post() common.Executor
getRunContext() *RunContext
getGithubContext(ctx context.Context) *model.GithubContext
getStepModel() *model.Step
getEnv() *map[string]string
getIfExpression(context context.Context, stage stepStage) string
}
func stepActionIdentity(step step) (repository, ref string) {
if action, ok := step.(interface{ actionIdentity() (string, string) }); ok {
return action.actionIdentity()
}
return "", ""
}
func getStepGithubContext(ctx context.Context, step step) *model.GithubContext {
github := step.getRunContext().getGithubContext(ctx)
github.ActionRepository, github.ActionRef = stepActionIdentity(step)
return github
}
type stepStage int
const (
@@ -92,6 +104,8 @@ func runStepExecutor(step step, stage stepStage, executor common.Executor) commo
runStep, err = isStepEnabled(ctx, ifExpression, step, stage)
}
if err == nil && runStep {
env := *step.getEnv()
env["GITHUB_ACTION_REPOSITORY"], env["GITHUB_ACTION_REF"] = stepActionIdentity(step)
err = setupInputs(ctx, step)
}
if err != nil {
@@ -253,7 +267,7 @@ func setupEnv(ctx context.Context, step step) error {
env := step.getEnv()
// container env is the image's baseline, which job env and $GITHUB_ENV override
mergeIntoMap(step, env, rc.containerSpec.Env, rc.GetEnv())
rc.withGithubEnv(ctx, step.getGithubContext(ctx), *env)
rc.withGithubEnv(ctx, getStepGithubContext(ctx, step), *env)
var err error
exprEval := rc.NewExpressionEvaluator(ctx)
@@ -302,7 +316,7 @@ func isStepEnabled(ctx context.Context, expr string, step step, stage stepStage)
if rc.Parent != nil && stage == stepStageMain && jobContext.Status != "cancelled" {
jobContext.Status = rc.ownStatus()
}
runStep, err := EvalBool(ctx, rc.newStepExpressionEvaluator(ctx, step, rc.actionInputs, jobContext), expr, defaultStatusCheck)
runStep, err := EvalBool(ctx, rc.newStepExpressionEvaluator(ctx, step, rc.actionInputs, jobContext, rc.getGithubContext(ctx)), expr, defaultStatusCheck)
if err != nil {
return false, fmt.Errorf("if-expression %q evaluation failed: %s", expr, err)
}