1
0
Fork 0
mirror of https://code.forgejo.org/forgejo/runner.git synced 2025-08-11 17:50:58 +00:00

chore: run_context: add GITHUB_RUN_ATTEMPT (#2458)

* run_context: add GITHUB_RUN_ATTEMPT

Fixes https://github.com/nektos/act/issues/2451
Fixes https://github.com/nektos/act/issues/1615

* fix whitespace

* fix githubcontext

* fix TestSetupEnv

---------

Co-authored-by: ChristopherHX <christopher.homberger@web.de>
Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
(cherry picked from commit 4178166d289bae351ef6d33414cc569518e62a01)

Conflicts:
	act/runner/run_context.go
    trivial context conflict
	act/runner/step_test.go
    the corresponding test was removed in the Forgejo runner
This commit is contained in:
Ryan 2024-09-19 23:36:09 +02:00 committed by Earl Warren
parent 96891ab314
commit ac38e2c000
No known key found for this signature in database
GPG key ID: 0579CB2928A78A00
2 changed files with 7 additions and 0 deletions

View file

@ -13,6 +13,7 @@ type GithubContext struct {
Event map[string]interface{} `json:"event"`
EventPath string `json:"event_path"`
Workflow string `json:"workflow"`
RunAttempt string `json:"run_attempt"`
RunID string `json:"run_id"`
RunNumber string `json:"run_number"`
Actor string `json:"actor"`

View file

@ -1108,6 +1108,7 @@ func (rc *RunContext) getGithubContext(ctx context.Context) *model.GithubContext
ghc := &model.GithubContext{
Event: make(map[string]interface{}),
Workflow: rc.Run.Workflow.Name,
RunAttempt: rc.Config.Env["GITHUB_RUN_ATTEMPT"],
RunID: rc.Config.Env["GITHUB_RUN_ID"],
RunNumber: rc.Config.Env["GITHUB_RUN_NUMBER"],
Actor: rc.Config.Actor,
@ -1136,6 +1137,10 @@ func (rc *RunContext) getGithubContext(ctx context.Context) *model.GithubContext
ghc.Workspace = rc.JobContainer.ToContainerPath(rc.Config.Workdir)
}
if ghc.RunAttempt == "" {
ghc.RunAttempt = "1"
}
if ghc.RunID == "" {
ghc.RunID = "1"
}
@ -1294,6 +1299,7 @@ func (rc *RunContext) withGithubEnv(ctx context.Context, github *model.GithubCon
}
env["CI"] = "true"
set("WORKFLOW", github.Workflow)
set("RUN_ATTEMPT", github.RunAttempt)
set("RUN_ID", github.RunID)
set("RUN_NUMBER", github.RunNumber)
set("ACTION", github.Action)