Reputation: 172
I'm using the Octokit API to request a specific workflow run. I can see in the documentation that I can request a specific workflow run by providing a workflow run 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?
E.g. the value of workflow-run-latest
here would always be changing.
octokit.actions.getWorkflowRun({
owner: owner,
repo: repo-name,
run_id: workflow-run-latest,
});
Thanks!
Upvotes: 5
Views: 2676
Reputation: 172
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
});
Upvotes: 4
Reputation: 42260
When using the list API it looks to me like the latest is always the first in the list. So one option might be to request with per_page
set to 1
so you only get the latest.
octokit.actions.listWorkflowRunsForRepo({
owner: owner,
repo: repo-name,
per_page: 1,
});
Upvotes: 6