From b3e7d6a62d6c00850616fddc199bef6bb65e8a85 Mon Sep 17 00:00:00 2001 From: Jason Song Date: Thu, 24 Nov 2022 14:47:51 +0800 Subject: [PATCH] fix: update container config --- go.mod | 2 +- go.sum | 4 ++-- runtime/task.go | 9 +++++++-- 3 files changed, 10 insertions(+), 5 deletions(-) diff --git a/go.mod b/go.mod index f9821cd..208816e 100644 --- a/go.mod +++ b/go.mod @@ -77,4 +77,4 @@ require ( gopkg.in/yaml.v3 v3.0.1 // indirect ) -replace github.com/nektos/act => gitea.com/gitea/act v0.233.4 +replace github.com/nektos/act => gitea.com/gitea/act v0.233.5 diff --git a/go.sum b/go.sum index 7e160ee..83007f2 100644 --- a/go.sum +++ b/go.sum @@ -25,8 +25,8 @@ cloud.google.com/go/storage v1.6.0/go.mod h1:N7U0C8pVQ/+NIKOBQyamJIeKQKkZ+mxpohl code.gitea.io/bots-proto-go v0.1.0 h1:H+01Pcb7j6+l3TDj/0YFOJvPYbcKkzSBXg1qoGz/qc8= code.gitea.io/bots-proto-go v0.1.0/go.mod h1:tZCdF4XQ1216T+JUHw2A091PA/QP3HLx7IXPv1l3v5c= dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU= -gitea.com/gitea/act v0.233.4 h1:ItqivoomnfTTeXZ/hqlSQFlgA0TBv40U3dbg0gYUYKk= -gitea.com/gitea/act v0.233.4/go.mod h1:QpHTbzW4rX/jfN9qnfPdPC5Us0JZPxfPeEaAv18VVrQ= +gitea.com/gitea/act v0.233.5 h1:XXJwuWC+J9XkWokCRg1s16Oc46aZ6gQ27MNd2C/RqHY= +gitea.com/gitea/act v0.233.5/go.mod h1:QpHTbzW4rX/jfN9qnfPdPC5Us0JZPxfPeEaAv18VVrQ= github.com/Azure/azure-sdk-for-go v16.2.1+incompatible/go.mod h1:9XXNKU+eRnpl9moKnB4QOLf1HestfXbmab5FXxiDBjc= github.com/Azure/go-ansiterm v0.0.0-20170929234023-d6e3b3328b78 h1:w+iIsaOQNcT7OZ575w+acHgRric5iCyQh+xv+KJ4HB8= github.com/Azure/go-ansiterm v0.0.0-20170929234023-d6e3b3328b78/go.mod h1:LmzpDX56iTiv29bbRTIsUNlaFfuhWRQBWjQdVyAevI8= diff --git a/runtime/task.go b/runtime/task.go index 062e40f..87b0cfa 100644 --- a/runtime/task.go +++ b/runtime/task.go @@ -191,6 +191,11 @@ func (t *Task) Run(ctx context.Context, task *runnerv1.Task) error { return err } + maxLifetime := 3 * time.Hour + if deadline, ok := ctx.Deadline(); ok { + maxLifetime = time.Until(deadline) + } + input := t.Input config := &runner.Config{ Workdir: "/" + preset.Repository, @@ -217,8 +222,8 @@ func (t *Task) Run(ctx context.Context, task *runnerv1.Task) error { NoSkipCheckout: true, PresetGitHubContext: preset, EventJSON: string(eventJSON), - ContainerNamePrefix: fmt.Sprintf("gitea-task-%d", task.Id), - ContainerMaxLifetime: 3 * time.Hour, // maybe should be specified by Gitea server + ContainerNamePrefix: fmt.Sprintf("GITEA-BOTS-TASK-%d", task.Id), + ContainerMaxLifetime: maxLifetime, ContainerNetworkMode: input.containerNetworkMode, DefaultActionInstance: dataContext["gitea_default_bots_url"].GetStringValue(), PlatformPicker: t.platformPicker,