[英]Get the latest workflow run from GitHub Actions using the Octokit API
I'm using the Octokit API to request a specific workflow run.我正在使用Octokit API请求运行特定的工作流。 I can see in the documentation that I can request a specific workflow run by providing a workflow run ID.
我可以在 文档中看到,我可以通过提供工作流运行 ID 来请求特定的工作流运行。 However I would like to always request the latest workflow run.
但是我想总是请求最新的工作流程运行。 How do I achieve this if I don't know what the ID will be?
如果我不知道 ID 是什么,我该如何实现?
Eg the value of workflow-run-latest
here would always be changing.例如,
workflow-run-latest
的值总是在变化。
octokit.actions.getWorkflowRun({
owner: owner,
repo: repo-name,
run_id: workflow-run-latest,
});
Thanks!谢谢!
When using the list API it looks to me like the latest is always the first in the list.在使用列表 API 时,在我看来,最新的总是列表中的第一个。 So one option might be to request with
per_page
set to 1
so you only get the latest.因此,一种选择可能是将
per_page
设置为1
进行请求,以便您只能获得最新的。
octokit.actions.listWorkflowRunsForRepo({
owner: owner,
repo: repo-name,
per_page: 1,
});
Just posting my code snippet that solved my problem here in case it helps anyone in the future :)只需在此处发布解决我问题的代码片段,以防将来对任何人有所帮助:)
var workflowRuns = octokit.actions.listWorkflowRuns({
owner: owner,
repo: 'repo-name',
workflow_file_name: 'file-name.yaml',
per_page: 1
});
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.