mirror of
https://gitea.com/gitea/act_runner.git
synced 2026-06-10 11:54:27 +02:00
This PR contains the following updates: | Package | Change | [Age](https://docs.renovatebot.com/merge-confidence/) | [Confidence](https://docs.renovatebot.com/merge-confidence/) | |---|---|---|---| | code.gitea.io/actions-proto-go | `v0.4.1` → `v0.5.0` |  |  | --- ### Configuration 📅 **Schedule**: (UTC) - Branch creation - At any time (no schedule defined) - Automerge - At any time (no schedule defined) 🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied. ♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox. 🔕 **Ignore**: Close this PR and you won't be reminded about this update again. --- - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box --- This PR has been generated by [Mend Renovate](https://github.com/renovatebot/renovate). <!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiI0My4xOTEuMiIsInVwZGF0ZWRJblZlciI6IjQzLjE5MS4yIiwidGFyZ2V0QnJhbmNoIjoibWFpbiIsImxhYmVscyI6W119--> --------- Co-authored-by: Nicolas <bircni@icloud.com> Reviewed-on: https://gitea.com/gitea/runner/pulls/1009 Reviewed-by: Lunny Xiao <xiaolunwen@gmail.com> Co-authored-by: Renovate Bot <renovate-bot@gitea.com> Co-committed-by: Renovate Bot <renovate-bot@gitea.com>
56 lines
1.2 KiB
Go
56 lines
1.2 KiB
Go
// Copyright 2023 The Gitea Authors. All rights reserved.
|
|
// SPDX-License-Identifier: MIT
|
|
|
|
package run
|
|
|
|
import (
|
|
"bytes"
|
|
"fmt"
|
|
"sort"
|
|
"strings"
|
|
|
|
"gitea.com/gitea/runner/act/model"
|
|
|
|
runnerv1 "gitea.dev/actions-proto-go/runner/v1"
|
|
"go.yaml.in/yaml/v4"
|
|
)
|
|
|
|
func generateWorkflow(task *runnerv1.Task) (*model.Workflow, string, error) {
|
|
workflow, err := model.ReadWorkflow(bytes.NewReader(task.WorkflowPayload))
|
|
if err != nil {
|
|
return nil, "", err
|
|
}
|
|
|
|
jobIDs := workflow.GetJobIDs()
|
|
if len(jobIDs) != 1 {
|
|
return nil, "", fmt.Errorf("multiple jobs found: %v", jobIDs)
|
|
}
|
|
jobID := jobIDs[0]
|
|
|
|
needJobIDs := make([]string, 0, len(task.Needs))
|
|
for id, need := range task.Needs {
|
|
needJobIDs = append(needJobIDs, id)
|
|
needJob := &model.Job{
|
|
Outputs: need.Outputs,
|
|
Result: strings.ToLower(strings.TrimPrefix(need.Result.String(), "RESULT_")),
|
|
}
|
|
workflow.Jobs[id] = needJob
|
|
}
|
|
sort.Strings(needJobIDs)
|
|
|
|
rawNeeds := yaml.Node{
|
|
Kind: yaml.SequenceNode,
|
|
Content: make([]*yaml.Node, 0, len(needJobIDs)),
|
|
}
|
|
for _, id := range needJobIDs {
|
|
rawNeeds.Content = append(rawNeeds.Content, &yaml.Node{
|
|
Kind: yaml.ScalarNode,
|
|
Value: id,
|
|
})
|
|
}
|
|
|
|
workflow.Jobs[jobID].RawNeeds = rawNeeds
|
|
|
|
return workflow, jobID, nil
|
|
}
|