Skip to content

Commit 79285e8

Browse files
earl-warrencatthehacker
andcommitted
chore: run_context: add GITHUB_RUN_ATTEMPT (#2458) (#817)
* run_context: add GITHUB_RUN_ATTEMPT Fixes nektos/act#2451 Fixes nektos/act#1615 * fix whitespace * fix githubcontext * fix TestSetupEnv --------- Co-authored-by: ChristopherHX <[email protected]> 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 ``` <!--start release-notes-assistant--> <!--URL:https://code.forgejo.org/forgejo/runner--> - other - [PR](https://code.forgejo.org/forgejo/runner/pulls/817): <!--number 817 --><!--line 0 --><!--description Y2hvcmU6IHJ1bl9jb250ZXh0OiBhZGQgR0lUSFVCX1JVTl9BVFRFTVBUICgjMjQ1OCk=-->chore: run_context: add GITHUB_RUN_ATTEMPT (#2458)<!--description--> <!--end release-notes-assistant--> Co-authored-by: Ryan <[email protected]> Reviewed-on: https://code.forgejo.org/forgejo/runner/pulls/817 Reviewed-by: Michael Kriese <[email protected]>
1 parent 96891ab commit 79285e8

File tree

2 files changed

+7
-0
lines changed

2 files changed

+7
-0
lines changed

act/model/github_context.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ type GithubContext struct {
1313
Event map[string]interface{} `json:"event"`
1414
EventPath string `json:"event_path"`
1515
Workflow string `json:"workflow"`
16+
RunAttempt string `json:"run_attempt"`
1617
RunID string `json:"run_id"`
1718
RunNumber string `json:"run_number"`
1819
Actor string `json:"actor"`

act/runner/run_context.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1108,6 +1108,7 @@ func (rc *RunContext) getGithubContext(ctx context.Context) *model.GithubContext
11081108
ghc := &model.GithubContext{
11091109
Event: make(map[string]interface{}),
11101110
Workflow: rc.Run.Workflow.Name,
1111+
RunAttempt: rc.Config.Env["GITHUB_RUN_ATTEMPT"],
11111112
RunID: rc.Config.Env["GITHUB_RUN_ID"],
11121113
RunNumber: rc.Config.Env["GITHUB_RUN_NUMBER"],
11131114
Actor: rc.Config.Actor,
@@ -1136,6 +1137,10 @@ func (rc *RunContext) getGithubContext(ctx context.Context) *model.GithubContext
11361137
ghc.Workspace = rc.JobContainer.ToContainerPath(rc.Config.Workdir)
11371138
}
11381139

1140+
if ghc.RunAttempt == "" {
1141+
ghc.RunAttempt = "1"
1142+
}
1143+
11391144
if ghc.RunID == "" {
11401145
ghc.RunID = "1"
11411146
}
@@ -1294,6 +1299,7 @@ func (rc *RunContext) withGithubEnv(ctx context.Context, github *model.GithubCon
12941299
}
12951300
env["CI"] = "true"
12961301
set("WORKFLOW", github.Workflow)
1302+
set("RUN_ATTEMPT", github.RunAttempt)
12971303
set("RUN_ID", github.RunID)
12981304
set("RUN_NUMBER", github.RunNumber)
12991305
set("ACTION", github.Action)

0 commit comments

Comments
 (0)