Skip to content

Commit 647d9dd

Browse files
ci: get latest workflow run id
1 parent e2bce45 commit 647d9dd

File tree

1 file changed

+18
-3
lines changed

1 file changed

+18
-3
lines changed

.github/workflows/invoke-workflow.yml

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,16 +32,31 @@ jobs:
3232
const ref = '${{ inputs.ref }}';
3333
const owner = context.repo.owner;
3434
35-
const result = await github.rest.actions.createWorkflowDispatch({
35+
await github.rest.actions.createWorkflowDispatch({
3636
owner,
3737
repo,
3838
workflow_id,
3939
ref,
4040
});
4141
42-
console.log(result)
42+
- name: Get workflow run_id
43+
uses: actions/github-script@v6
44+
with:
45+
script: |-
46+
const owner = context.repo.owner;
47+
const workflow_id = '${{ inputs.workflow }}';
48+
const repo = '${{ inputs.repo }}';
49+
50+
const runs = await github.rest.actions.listWorkflowRuns({
51+
owner,
52+
repo,
53+
workflow_id,
54+
per_page: 1,
55+
});
56+
57+
console.log(runs);
4358
44-
const run_id = result.run_id;
59+
const run_id = runs[0].id;
4560
4661
core.setOutput('run-id', run_id);
4762

0 commit comments

Comments
 (0)