diff options
author | Nanguan Lin <nanguanlin6@gmail.com> | 2024-02-28 01:56:18 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-02-27 18:56:18 +0100 |
commit | db545b208b4bd3d1961c519da66ee2b4421afa5c (patch) | |
tree | c63ec0ac9895b40a16b36cae9b246e973f849f4d /models/actions/run.go | |
parent | e9f4c2db8291c54044345aebd9381ac820ed9687 (diff) | |
download | gitea-db545b208b4bd3d1961c519da66ee2b4421afa5c.tar.gz gitea-db545b208b4bd3d1961c519da66ee2b4421afa5c.zip |
Implement actions badge svgs (#28102)
replace #27187
close #23688
The badge has two parts: label(workflow name) and message(action
status). 5 colors are provided with 7 statuses.
Color mapping:
```go
var statusColorMap = map[actions_model.Status]string{
actions_model.StatusSuccess: "#4c1", // Green
actions_model.StatusSkipped: "#dfb317", // Yellow
actions_model.StatusUnknown: "#97ca00", // Light Green
actions_model.StatusFailure: "#e05d44", // Red
actions_model.StatusCancelled: "#fe7d37", // Orange
actions_model.StatusWaiting: "#dfb317", // Yellow
actions_model.StatusRunning: "#dfb317", // Yellow
actions_model.StatusBlocked: "#dfb317", // Yellow
}
```
preview:
![1](https://github.com/go-gitea/gitea/assets/70063547/5465cbaf-23cd-4437-9848-2738c3cb8985)
![2](https://github.com/go-gitea/gitea/assets/70063547/ec393d26-c6e6-4d38-b72c-51f2494c5e71)
![3](https://github.com/go-gitea/gitea/assets/70063547/3edb4fdf-1b08-4a02-ab2a-6bdd7f532fb2)
![4](https://github.com/go-gitea/gitea/assets/70063547/8c189de2-2169-4251-b115-0e39a52f3df8)
![5](https://github.com/go-gitea/gitea/assets/70063547/3fe22c73-c2d7-4fec-9ea4-c501a1e4e3bd)
---------
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-authored-by: Giteabot <teabot@gitea.io>
Co-authored-by: delvh <dev.lh@web.de>
Diffstat (limited to 'models/actions/run.go')
-rw-r--r-- | models/actions/run.go | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/models/actions/run.go b/models/actions/run.go index fcac58d515..7b3125949b 100644 --- a/models/actions/run.go +++ b/models/actions/run.go @@ -339,6 +339,23 @@ func GetRunByIndex(ctx context.Context, repoID, index int64) (*ActionRun, error) return run, nil } +func GetWorkflowLatestRun(ctx context.Context, repoID int64, workflowFile, branch, event string) (*ActionRun, error) { + var run ActionRun + q := db.GetEngine(ctx).Where("repo_id=?", repoID). + And("ref = ?", branch). + And("workflow_id = ?", workflowFile) + if event != "" { + q.And("event = ?", event) + } + has, err := q.Desc("id").Get(&run) + if err != nil { + return nil, err + } else if !has { + return nil, util.NewNotExistErrorf("run with repo_id %d, ref %s, workflow_id %s", repoID, branch, workflowFile) + } + return &run, nil +} + // UpdateRun updates a run. // It requires the inputted run has Version set. // It will return error if the version is not matched (it means the run has been changed after loaded). |