From 647d9dd3821ad2f13c70fc4d3f9baaf3b4fec721 Mon Sep 17 00:00:00 2001 From: levisingularity Date: Fri, 19 Jul 2024 10:44:52 -0300 Subject: [PATCH] ci: get latest workflow run id --- .github/workflows/invoke-workflow.yml | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/.github/workflows/invoke-workflow.yml b/.github/workflows/invoke-workflow.yml index 75814fd..5ace483 100644 --- a/.github/workflows/invoke-workflow.yml +++ b/.github/workflows/invoke-workflow.yml @@ -32,16 +32,31 @@ jobs: const ref = '${{ inputs.ref }}'; const owner = context.repo.owner; - const result = await github.rest.actions.createWorkflowDispatch({ + await github.rest.actions.createWorkflowDispatch({ owner, repo, workflow_id, ref, }); - console.log(result) + - name: Get workflow run_id + uses: actions/github-script@v6 + with: + script: |- + const owner = context.repo.owner; + const workflow_id = '${{ inputs.workflow }}'; + const repo = '${{ inputs.repo }}'; + + const runs = await github.rest.actions.listWorkflowRuns({ + owner, + repo, + workflow_id, + per_page: 1, + }); + + console.log(runs); - const run_id = result.run_id; + const run_id = runs[0].id; core.setOutput('run-id', run_id);