feat: support custom GITHUB_RUN_ID, GITHUB_RUN_NUMBER (#369)

* feat: add fromJSON support

* feat: support custom runId and runNumber

* chore: manual update

* chore: lint
This commit is contained in:
Owen 2020-09-23 05:13:29 +08:00 committed by GitHub
parent 04456ad234
commit 1070c58538
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 11 additions and 5 deletions

1
.actrc
View file

@ -1 +0,0 @@
-P ubuntu-latest=nektos/act-environments-ubuntu:18.04

View file

@ -15,7 +15,7 @@ build:
.PHONY: test .PHONY: test
test: test:
$(ACT) $(ACT) -W examples/workflows --verbose
.PHONY: install .PHONY: install
install: build install: build

View file

@ -351,13 +351,20 @@ func (rc *RunContext) getGithubContext() *githubContext {
if !ok { if !ok {
token = os.Getenv("GITHUB_TOKEN") token = os.Getenv("GITHUB_TOKEN")
} }
runID := rc.Config.Env["GITHUB_RUN_ID"]
if(runID == ""){
runID = "1"
}
runNumber := rc.Config.Env["GITHUB_RUN_NUMBER"]
if(runNumber == ""){
runNumber = "1"
}
ghc := &githubContext{ ghc := &githubContext{
Event: make(map[string]interface{}), Event: make(map[string]interface{}),
EventPath: "/github/workflow/event.json", EventPath: "/github/workflow/event.json",
Workflow: rc.Run.Workflow.Name, Workflow: rc.Run.Workflow.Name,
RunID: "1", RunID: runID,
RunNumber: "1", RunNumber: runNumber,
Actor: rc.Config.Actor, Actor: rc.Config.Actor,
EventName: rc.Config.EventName, EventName: rc.Config.EventName,
Token: token, Token: token,