0
0
mirror of https://github.com/go-gitea/gitea.git synced 2025-07-21 16:45:03 +02:00
This commit is contained in:
Christopher Homberger 2025-03-21 15:48:00 +01:00
parent b650ca9239
commit 8cfb047983
7 changed files with 270 additions and 9 deletions

View File

@ -716,7 +716,7 @@ func matchWorkflowRunEvent(payload *api.WorkflowRunPayload, evt *jobparser.Event
case "types":
action := payload.Action
for _, val := range vals {
if glob.MustCompile(val, '/').Match(string(action)) {
if glob.MustCompile(val, '/').Match(action) {
matchTimes++
break
}

View File

@ -1017,7 +1017,6 @@ func GetWorkflowRun(ctx *context.APIContext) {
return
}
ctx.JSON(http.StatusOK, convertedArtifact)
return
}
// GetWorkflowJobs Lists all jobs for a workflow run.
@ -1130,7 +1129,6 @@ func GetWorkflowJob(ctx *context.APIContext) {
return
}
ctx.JSON(http.StatusOK, convertedWorkflowJob)
return
}
// GetArtifacts Lists all artifacts for a repository.

View File

@ -10,7 +10,6 @@ import (
issues_model "code.gitea.io/gitea/models/issues"
"code.gitea.io/gitea/models/organization"
packages_model "code.gitea.io/gitea/models/packages"
"code.gitea.io/gitea/models/perm"
perm_model "code.gitea.io/gitea/models/perm"
access_model "code.gitea.io/gitea/models/perm/access"
repo_model "code.gitea.io/gitea/models/repo"
@ -785,7 +784,10 @@ func (n *actionsNotifier) WorkflowRunStatusUpdate(ctx context.Context, repo *rep
defer gitRepo.Close()
convertedWorkflow, err := convert.GetActionWorkflow(ctx, gitRepo, repo, run.WorkflowID)
if err != nil {
log.Error("GetActionWorkflow: %v", err)
return
}
convertedRun, err := convert.ToActionWorkflowRun(ctx, repo, run)
if err != nil {
log.Error("ToActionWorkflowRun: %v", err)
@ -797,7 +799,7 @@ func (n *actionsNotifier) WorkflowRunStatusUpdate(ctx context.Context, repo *rep
Workflow: convertedWorkflow,
WorkflowRun: convertedRun,
Organization: org,
Repo: convert.ToRepo(ctx, repo, access_model.Permission{AccessMode: perm.AccessModeOwner}),
Repo: convert.ToRepo(ctx, repo, access_model.Permission{AccessMode: perm_model.AccessModeOwner}),
Sender: convert.ToUser(ctx, sender, nil),
}).Notify(ctx)
}

View File

@ -235,7 +235,10 @@ func ToActionTask(ctx context.Context, t *actions_model.ActionTask) (*api.Action
}
func ToActionWorkflowRun(ctx context.Context, repo *repo_model.Repository, run *actions_model.ActionRun) (*api.ActionWorkflowRun, error) {
run.LoadRepo(ctx)
err := run.LoadRepo(ctx)
if err != nil {
return nil, err
}
status, conclusion := ToActionsStatus(run.Status)
return &api.ActionWorkflowRun{
ID: run.ID,

View File

@ -995,6 +995,10 @@ func (*webhookNotifier) WorkflowRunStatusUpdate(ctx context.Context, repo *repo_
defer gitRepo.Close()
convertedWorkflow, err := convert.GetActionWorkflow(ctx, gitRepo, repo, run.WorkflowID)
if err != nil {
log.Error("GetActionWorkflow: %v", err)
return
}
convertedRun, err := convert.ToActionWorkflowRun(ctx, repo, run)
if err != nil {

View File

@ -4187,6 +4187,52 @@
}
}
},
"/repos/{owner}/{repo}/actions/jobs/{job_id}": {
"get": {
"produces": [
"application/json"
],
"tags": [
"repository"
],
"summary": "Gets a specific workflow job for a workflow run",
"operationId": "getWorkflowJob",
"parameters": [
{
"type": "string",
"description": "name of the owner",
"name": "owner",
"in": "path",
"required": true
},
{
"type": "string",
"description": "name of the repository",
"name": "repo",
"in": "path",
"required": true
},
{
"type": "string",
"description": "id of the job",
"name": "job_id",
"in": "path",
"required": true
}
],
"responses": {
"200": {
"$ref": "#/responses/Artifact"
},
"400": {
"$ref": "#/responses/error"
},
"404": {
"$ref": "#/responses/notFound"
}
}
}
},
"/repos/{owner}/{repo}/actions/runners/registration-token": {
"get": {
"produces": [
@ -4220,6 +4266,104 @@
}
}
},
"/repos/{owner}/{repo}/actions/runs": {
"get": {
"produces": [
"application/json"
],
"tags": [
"repository"
],
"summary": "Lists all runs for a repository run",
"operationId": "getWorkflowRuns",
"parameters": [
{
"type": "string",
"description": "name of the owner",
"name": "owner",
"in": "path",
"required": true
},
{
"type": "string",
"description": "name of the repository",
"name": "repo",
"in": "path",
"required": true
},
{
"type": "integer",
"description": "runid of the workflow run",
"name": "run",
"in": "path",
"required": true
},
{
"type": "string",
"description": "name of the artifact",
"name": "name",
"in": "query"
}
],
"responses": {
"200": {
"$ref": "#/responses/ArtifactsList"
},
"400": {
"$ref": "#/responses/error"
},
"404": {
"$ref": "#/responses/notFound"
}
}
}
},
"/repos/{owner}/{repo}/actions/runs/{run}": {
"get": {
"produces": [
"application/json"
],
"tags": [
"repository"
],
"summary": "Gets a specific workflow run",
"operationId": "GetWorkflowRun",
"parameters": [
{
"type": "string",
"description": "name of the owner",
"name": "owner",
"in": "path",
"required": true
},
{
"type": "string",
"description": "name of the repository",
"name": "repo",
"in": "path",
"required": true
},
{
"type": "string",
"description": "id of the run",
"name": "run",
"in": "path",
"required": true
}
],
"responses": {
"200": {
"$ref": "#/responses/Artifact"
},
"400": {
"$ref": "#/responses/error"
},
"404": {
"$ref": "#/responses/notFound"
}
}
}
},
"/repos/{owner}/{repo}/actions/runs/{run}/artifacts": {
"get": {
"produces": [
@ -4272,6 +4416,58 @@
}
}
},
"/repos/{owner}/{repo}/actions/runs/{run}/jobs": {
"get": {
"produces": [
"application/json"
],
"tags": [
"repository"
],
"summary": "Lists all jobs for a workflow run",
"operationId": "getWorkflowJobs",
"parameters": [
{
"type": "string",
"description": "name of the owner",
"name": "owner",
"in": "path",
"required": true
},
{
"type": "string",
"description": "name of the repository",
"name": "repo",
"in": "path",
"required": true
},
{
"type": "integer",
"description": "runid of the workflow run",
"name": "run",
"in": "path",
"required": true
},
{
"type": "string",
"description": "name of the artifact",
"name": "name",
"in": "query"
}
],
"responses": {
"200": {
"$ref": "#/responses/ArtifactsList"
},
"400": {
"$ref": "#/responses/error"
},
"404": {
"$ref": "#/responses/notFound"
}
}
}
},
"/repos/{owner}/{repo}/actions/secrets": {
"get": {
"produces": [
@ -19404,19 +19600,77 @@
"description": "ActionWorkflowRun represents a WorkflowRun",
"type": "object",
"properties": {
"completed_at": {
"type": "string",
"format": "date-time",
"x-go-name": "CompletedAt"
},
"conclusion": {
"type": "string",
"x-go-name": "Conclusion"
},
"display_title": {
"type": "string",
"x-go-name": "DisplayTitle"
},
"event": {
"type": "string",
"x-go-name": "Event"
},
"head_branch": {
"type": "string",
"x-go-name": "HeadBranch"
},
"head_repository": {
"$ref": "#/definitions/Repository"
},
"head_sha": {
"type": "string",
"x-go-name": "HeadSha"
},
"html_url": {
"type": "string",
"x-go-name": "HTMLURL"
},
"id": {
"type": "integer",
"format": "int64",
"x-go-name": "ID"
},
"path": {
"type": "string",
"x-go-name": "Path"
},
"repository": {
"$ref": "#/definitions/Repository"
},
"repository_id": {
"type": "integer",
"format": "int64",
"x-go-name": "RepositoryID"
},
"run_attempt": {
"type": "integer",
"format": "int64",
"x-go-name": "RunAttempt"
},
"run_number": {
"type": "integer",
"format": "int64",
"x-go-name": "RunNumber"
},
"started_at": {
"type": "string",
"format": "date-time",
"x-go-name": "StartedAt"
},
"status": {
"type": "string",
"x-go-name": "Status"
},
"url": {
"type": "string",
"x-go-name": "URL"
}
},
"x-go-package": "code.gitea.io/gitea/modules/structs"

View File

@ -707,7 +707,7 @@ jobs:
assert.EqualValues(t, commitID, payloads[3].WorkflowJob.HeadSha)
assert.EqualValues(t, "repo1", payloads[3].Repo.Name)
assert.EqualValues(t, "user2/repo1", payloads[3].Repo.FullName)
assert.Contains(t, payloads[3].WorkflowJob.URL, fmt.Sprintf("/actions/runs/%d/jobs/%d", payloads[3].WorkflowJob.RunID, payloads[3].WorkflowJob.ID))
assert.Contains(t, payloads[3].WorkflowJob.URL, fmt.Sprintf("/actions/jobs/%d", payloads[3].WorkflowJob.ID))
assert.Contains(t, payloads[3].WorkflowJob.URL, payloads[3].WorkflowJob.RunURL)
assert.Contains(t, payloads[3].WorkflowJob.HTMLURL, fmt.Sprintf("/jobs/%d", 0))
assert.Len(t, payloads[3].WorkflowJob.Steps, 1)
@ -745,7 +745,7 @@ jobs:
assert.EqualValues(t, commitID, payloads[6].WorkflowJob.HeadSha)
assert.EqualValues(t, "repo1", payloads[6].Repo.Name)
assert.EqualValues(t, "user2/repo1", payloads[6].Repo.FullName)
assert.Contains(t, payloads[6].WorkflowJob.URL, fmt.Sprintf("/actions/runs/%d/jobs/%d", payloads[6].WorkflowJob.RunID, payloads[6].WorkflowJob.ID))
assert.Contains(t, payloads[6].WorkflowJob.URL, fmt.Sprintf("/actions/jobs/%d", payloads[6].WorkflowJob.ID))
assert.Contains(t, payloads[6].WorkflowJob.URL, payloads[6].WorkflowJob.RunURL)
assert.Contains(t, payloads[6].WorkflowJob.HTMLURL, fmt.Sprintf("/jobs/%d", 1))
assert.Len(t, payloads[6].WorkflowJob.Steps, 2)