Skip to content

Commit

Permalink
Use a better endpoint for backport workflows runs (dotnet#69617)
Browse files Browse the repository at this point in the history
  • Loading branch information
am11 authored May 23, 2022
1 parent a0ff92c commit 017905c
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions .github/workflows/backport.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit 017905c

Please sign in to comment.