mirror of
https://github.com/go-gitea/gitea
synced 2024-11-19 00:11:24 +01:00
Avoid too long names for actions (#23162)
The name of the job or step comes from the workflow file, while the name of the runner comes from its registration. If the strings used for these names are too long, they could cause db issues.
This commit is contained in:
parent
067b0c2664
commit
cbc9a0fe47
3 changed files with 6 additions and 2 deletions
|
@ -192,6 +192,7 @@ func InsertRun(ctx context.Context, run *ActionRun, jobs []*jobparser.SingleWork
|
||||||
if len(needs) > 0 || run.NeedApproval {
|
if len(needs) > 0 || run.NeedApproval {
|
||||||
status = StatusBlocked
|
status = StatusBlocked
|
||||||
}
|
}
|
||||||
|
job.Name, _ = util.SplitStringAtByteN(job.Name, 255)
|
||||||
runJobs = append(runJobs, &ActionRunJob{
|
runJobs = append(runJobs, &ActionRunJob{
|
||||||
RunID: run.ID,
|
RunID: run.ID,
|
||||||
RepoID: run.RepoID,
|
RepoID: run.RepoID,
|
||||||
|
|
|
@ -298,8 +298,9 @@ func CreateTaskForRunner(ctx context.Context, runner *ActionRunner) (*ActionTask
|
||||||
if len(workflowJob.Steps) > 0 {
|
if len(workflowJob.Steps) > 0 {
|
||||||
steps := make([]*ActionTaskStep, len(workflowJob.Steps))
|
steps := make([]*ActionTaskStep, len(workflowJob.Steps))
|
||||||
for i, v := range workflowJob.Steps {
|
for i, v := range workflowJob.Steps {
|
||||||
|
name, _ := util.SplitStringAtByteN(v.String(), 255)
|
||||||
steps[i] = &ActionTaskStep{
|
steps[i] = &ActionTaskStep{
|
||||||
Name: v.String(),
|
Name: name,
|
||||||
TaskID: task.ID,
|
TaskID: task.ID,
|
||||||
Index: int64(i),
|
Index: int64(i),
|
||||||
RepoID: task.RepoID,
|
RepoID: task.RepoID,
|
||||||
|
|
|
@ -12,6 +12,7 @@ import (
|
||||||
"code.gitea.io/gitea/modules/actions"
|
"code.gitea.io/gitea/modules/actions"
|
||||||
"code.gitea.io/gitea/modules/json"
|
"code.gitea.io/gitea/modules/json"
|
||||||
"code.gitea.io/gitea/modules/log"
|
"code.gitea.io/gitea/modules/log"
|
||||||
|
"code.gitea.io/gitea/modules/util"
|
||||||
actions_service "code.gitea.io/gitea/services/actions"
|
actions_service "code.gitea.io/gitea/services/actions"
|
||||||
|
|
||||||
runnerv1 "code.gitea.io/actions-proto-go/runner/v1"
|
runnerv1 "code.gitea.io/actions-proto-go/runner/v1"
|
||||||
|
@ -55,9 +56,10 @@ func (s *Service) Register(
|
||||||
}
|
}
|
||||||
|
|
||||||
// create new runner
|
// create new runner
|
||||||
|
name, _ := util.SplitStringAtByteN(req.Msg.Name, 255)
|
||||||
runner := &actions_model.ActionRunner{
|
runner := &actions_model.ActionRunner{
|
||||||
UUID: gouuid.New().String(),
|
UUID: gouuid.New().String(),
|
||||||
Name: req.Msg.Name,
|
Name: name,
|
||||||
OwnerID: runnerToken.OwnerID,
|
OwnerID: runnerToken.OwnerID,
|
||||||
RepoID: runnerToken.RepoID,
|
RepoID: runnerToken.RepoID,
|
||||||
AgentLabels: req.Msg.AgentLabels,
|
AgentLabels: req.Msg.AgentLabels,
|
||||||
|
|
Loading…
Reference in a new issue