gitea源码

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. // Copyright 2025 The Gitea Authors. All rights reserved.
  2. // SPDX-License-Identifier: MIT
  3. package repo
  4. import (
  5. "errors"
  6. actions_model "code.gitea.io/gitea/models/actions"
  7. "code.gitea.io/gitea/modules/util"
  8. "code.gitea.io/gitea/routers/common"
  9. "code.gitea.io/gitea/services/context"
  10. )
  11. func DownloadActionsRunJobLogs(ctx *context.APIContext) {
  12. // swagger:operation GET /repos/{owner}/{repo}/actions/jobs/{job_id}/logs repository downloadActionsRunJobLogs
  13. // ---
  14. // summary: Downloads the job logs for a workflow run
  15. // produces:
  16. // - application/json
  17. // parameters:
  18. // - name: owner
  19. // in: path
  20. // description: owner of the repo
  21. // type: string
  22. // required: true
  23. // - name: repo
  24. // in: path
  25. // description: name of the repository
  26. // type: string
  27. // required: true
  28. // - name: job_id
  29. // in: path
  30. // description: id of the job
  31. // type: integer
  32. // required: true
  33. // responses:
  34. // "200":
  35. // description: output blob content
  36. // "400":
  37. // "$ref": "#/responses/error"
  38. // "404":
  39. // "$ref": "#/responses/notFound"
  40. jobID := ctx.PathParamInt64("job_id")
  41. curJob, err := actions_model.GetRunJobByID(ctx, jobID)
  42. if err != nil {
  43. ctx.APIErrorInternal(err)
  44. return
  45. }
  46. if err = curJob.LoadRepo(ctx); err != nil {
  47. ctx.APIErrorInternal(err)
  48. return
  49. }
  50. err = common.DownloadActionsRunJobLogs(ctx.Base, ctx.Repo.Repository, curJob)
  51. if err != nil {
  52. if errors.Is(err, util.ErrNotExist) {
  53. ctx.APIErrorNotFound(err)
  54. } else {
  55. ctx.APIErrorInternal(err)
  56. }
  57. }
  58. }