From 017905c855e28abeb250ae84198c6404515036e8 Mon Sep 17 00:00:00 2001 From: Adeel Mujahid <3840695+am11@users.noreply.github.com> Date: Mon, 23 May 2022 18:31:52 +0300 Subject: [PATCH] Use a better endpoint for backport workflows runs (#69617) --- .github/workflows/backport.yml | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/.github/workflows/backport.yml b/.github/workflows/backport.yml index 3f7a3dd..68b18cf 100644 --- a/.github/workflows/backport.yml +++ b/.github/workflows/backport.yml @@ -22,12 +22,16 @@ jobs: steps: - name: Delete old workflow runs run: | - _UrlPath="/repos/$GITHUB_REPOSITORY/actions/runs" + _UrlPath="/repos/$GITHUB_REPOSITORY/actions/workflows" + + _CurrentWorkflowID="$(gh api -X GET "$_UrlPath" | jq '.workflows[] | select(.name == '\""$GITHUB_WORKFLOW"\"') | .id')" + + _UrlPath="$_UrlPath/$_CurrentWorkflowID/runs" # delete workitems which are 'completed'. (other candidate values of status field are: 'queued' and 'in_progress') gh api -X GET "$_UrlPath" --paginate \ - | jq '.workflow_runs[] | select(.name == '\""$GITHUB_WORKFLOW"\"' and .status == "completed") | .id' \ + | jq '.workflow_runs[] | select(.status == "completed") | .id' \ | xargs -I{} gh api -X DELETE "$_UrlPath"/{} backport: -- 2.7.4