File tree 2 files changed +12
-5
lines changed
2 files changed +12
-5
lines changed Original file line number Diff line number Diff line change @@ -12,5 +12,5 @@ gh extension install skshetry/gh-cancel-runs
12
12
## Usage
13
13
14
14
```
15
- gh cancel-runs <owner>/<repo>
15
+ gh cancel-runs [ <owner>/<repo>]
16
16
```
Original file line number Diff line number Diff line change 1
1
#! /bin/bash
2
2
if [ $# -eq 0 ]
3
3
then
4
- echo " Usage: gh cancel-runs <owner>/<name>"
5
- exit 1
4
+ repo=$( gh repo view --json=nameWithOwner --jq " .nameWithOwner" | tee)
5
+ echo " Using repo: $repo "
6
+ else
7
+ repo=$1
6
8
fi
7
9
8
10
# from: https://stackoverflow.com/a/60766849/5693170
9
11
# modified to be used as a gh extension to avoid specifying tokens
10
12
11
13
# Using tee to disable pager
12
- ids=($( gh api repos/$1 /actions/runs --jq \
14
+ ids=($( gh api repos/$repo /actions/runs --jq \
13
15
' .workflow_runs[] | select([.status] | inside(["in_progress", "queued"])) | .id' \
14
16
| tee) )
15
17
18
+ if [ ${# ids[@]} -eq 0 ]; then
19
+ echo " No scheduled runs to cancel."
20
+ exit
21
+ fi
22
+
16
23
for id in $ids
17
24
do
18
25
echo " Cancelling $id "
19
- gh api -X POST repos/$1 /actions/runs/$id /cancel | tee
26
+ gh api -X POST repos/$repo /actions/runs/$id /cancel | tee
20
27
done
21
28
echo
You can’t perform that action at this time.
0 commit comments