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>
This commit is contained in:
@@ -13,6 +13,7 @@ type GithubContext struct {
|
|||||||
Event map[string]interface{} `json:"event"`
|
Event map[string]interface{} `json:"event"`
|
||||||
EventPath string `json:"event_path"`
|
EventPath string `json:"event_path"`
|
||||||
Workflow string `json:"workflow"`
|
Workflow string `json:"workflow"`
|
||||||
|
RunAttempt string `json:"run_attempt"`
|
||||||
RunID string `json:"run_id"`
|
RunID string `json:"run_id"`
|
||||||
RunNumber string `json:"run_number"`
|
RunNumber string `json:"run_number"`
|
||||||
Actor string `json:"actor"`
|
Actor string `json:"actor"`
|
||||||
|
|||||||
@@ -858,6 +858,7 @@ func (rc *RunContext) getGithubContext(ctx context.Context) *model.GithubContext
|
|||||||
ghc := &model.GithubContext{
|
ghc := &model.GithubContext{
|
||||||
Event: make(map[string]interface{}),
|
Event: make(map[string]interface{}),
|
||||||
Workflow: rc.Run.Workflow.Name,
|
Workflow: rc.Run.Workflow.Name,
|
||||||
|
RunAttempt: rc.Config.Env["GITHUB_RUN_ATTEMPT"],
|
||||||
RunID: rc.Config.Env["GITHUB_RUN_ID"],
|
RunID: rc.Config.Env["GITHUB_RUN_ID"],
|
||||||
RunNumber: rc.Config.Env["GITHUB_RUN_NUMBER"],
|
RunNumber: rc.Config.Env["GITHUB_RUN_NUMBER"],
|
||||||
Actor: rc.Config.Actor,
|
Actor: rc.Config.Actor,
|
||||||
@@ -886,6 +887,10 @@ func (rc *RunContext) getGithubContext(ctx context.Context) *model.GithubContext
|
|||||||
ghc.Workspace = rc.JobContainer.ToContainerPath(rc.Config.Workdir)
|
ghc.Workspace = rc.JobContainer.ToContainerPath(rc.Config.Workdir)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ghc.RunAttempt == "" {
|
||||||
|
ghc.RunAttempt = "1"
|
||||||
|
}
|
||||||
|
|
||||||
if ghc.RunID == "" {
|
if ghc.RunID == "" {
|
||||||
ghc.RunID = "1"
|
ghc.RunID = "1"
|
||||||
}
|
}
|
||||||
@@ -997,6 +1002,7 @@ func nestedMapLookup(m map[string]interface{}, ks ...string) (rval interface{})
|
|||||||
func (rc *RunContext) withGithubEnv(ctx context.Context, github *model.GithubContext, env map[string]string) map[string]string {
|
func (rc *RunContext) withGithubEnv(ctx context.Context, github *model.GithubContext, env map[string]string) map[string]string {
|
||||||
env["CI"] = "true"
|
env["CI"] = "true"
|
||||||
env["GITHUB_WORKFLOW"] = github.Workflow
|
env["GITHUB_WORKFLOW"] = github.Workflow
|
||||||
|
env["GITHUB_RUN_ATTEMPT"] = github.RunAttempt
|
||||||
env["GITHUB_RUN_ID"] = github.RunID
|
env["GITHUB_RUN_ID"] = github.RunID
|
||||||
env["GITHUB_RUN_NUMBER"] = github.RunNumber
|
env["GITHUB_RUN_NUMBER"] = github.RunNumber
|
||||||
env["GITHUB_ACTION"] = github.Action
|
env["GITHUB_ACTION"] = github.Action
|
||||||
|
|||||||
@@ -182,6 +182,7 @@ func TestSetupEnv(t *testing.T) {
|
|||||||
"GITHUB_RETENTION_DAYS": "0",
|
"GITHUB_RETENTION_DAYS": "0",
|
||||||
"GITHUB_RUN_ID": "runId",
|
"GITHUB_RUN_ID": "runId",
|
||||||
"GITHUB_RUN_NUMBER": "1",
|
"GITHUB_RUN_NUMBER": "1",
|
||||||
|
"GITHUB_RUN_ATTEMPT": "1",
|
||||||
"GITHUB_SERVER_URL": "https://",
|
"GITHUB_SERVER_URL": "https://",
|
||||||
"GITHUB_WORKFLOW": "",
|
"GITHUB_WORKFLOW": "",
|
||||||
"INPUT_STEP_WITH": "with-value",
|
"INPUT_STEP_WITH": "with-value",
|
||||||
|
|||||||
Reference in New Issue
Block a user