4

I want to get the job logs of a current workflow from Github Actions through a nodejs backend. I know that Github provides an API, to access informations about a workflow like this:

GET /repos/{owner}/{repo}/actions/workflows/{workflow_id}/runs

with a response like this:

{
  "total_count": 1,
  "workflow_runs": [
    {
      "id": 30433642,
      "node_id": "MDEyOldvcmtmbG93IFJ1bjI2OTI4OQ==",
      "head_branch": "master",
      "head_sha": "acb5820ced9479c074f688cc328bf03f341a511d",
      "run_number": 562,
      "event": "push",
      "status": "queued",
      "conclusion": null,
      "workflow_id": 159038,
      "url": "https://api.github.com/repos/octo-org/octo-repo/actions/runs/30433642",
      "html_url": "https://github.com/octo-org/octo-repo/actions/runs/30433642",
      "pull_requests": [],
      "created_at": "2020-01-22T19:33:08Z",
      "updated_at": "2020-01-22T19:33:08Z",
      "jobs_url": "https://api.github.com/repos/octo-org/octo-repo/actions/runs/30433642/jobs",
      "logs_url": "https://api.github.com/repos/octo-org/octo-repo/actions/runs/30433642/logs",
      "check_suite_url": "https://api.github.com/repos/octo-org/octo-repo/check-suites/414944374",
      "artifacts_url": "https://api.github.com/repos/octo-org/octo-repo/actions/runs/30433642/artifacts",
      "cancel_url": "https://api.github.com/repos/octo-org/octo-repo/actions/runs/30433642/cancel",
      "rerun_url": "https://api.github.com/repos/octo-org/octo-repo/actions/runs/30433642/rerun",
      "workflow_url": "https://api.github.com/repos/octo-org/octo-repo/actions/workflows/159038",
      "head_commit": {...},
      "repository": {...},
      "head_repository": {...}
  ]
}

From this stackoverflow question, I learned that you can get more information about the current build logs via the job_url, but does this take place in real time? Is there a way to stream the current logs, so i am able to display them on my own webpage?

Background: I want to trigger a workflow with an HTTP request using dispatch-event and after that, i want to display the current job logs on my own UI

Niklas
  • 1,638
  • 4
  • 19
  • 48
  • AFAIK (from having tried to do this myself), there is no way to get the logs of a _job_ that is currently executing. However, once that job is complete, the logs will be made available for download using that `logs_url` URL. – wheeler Mar 20 '23 at 17:23

0 Answers0