-
Notifications
You must be signed in to change notification settings - Fork 0
/
GitHubDisabledWorkflowList.sh
executable file
·89 lines (78 loc) · 2.06 KB
/
GitHubDisabledWorkflowList.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
#!/usr/bin/env bash
#
# Create a list of manually disabled workflows
# PreReqs:
# github cli, jq, sort installed
# GH_TOKEN set in env or login via gh cli
#
# TODO(kernelsam): Read token from lastpass
#
############################################################
# help
############################################################
help()
{
# Display Help
echo
echo "Syntax: GitHubIssueSearch.sh [-h|t]"
echo "options:"
echo "f Fields to search. Comma separated list. Ex. \"name,description,updatedAt"\"
echo "h Print this Help."
echo "l Maximum number of repositories to list"
echo "o github org"
echo
}
############################################################
# read args
############################################################
while [ -n "$1" ]; do
case "$1" in
--fields|-f)
shift
fields="${1:-name}"
;;
--help|-h)
shift
echo "You entered number as: $1"
;;
--limit|-l)
shift
limit="${1:-500}"
;;
--org|-o)
shift
org=$1
;;
*)
help
exit 1
;;
esac
shift
done
if [ ! -n "$org" ]; then
echo "[ERROR] Org was not provided"
exit 1
fi
############################################################
# main
# list gh repos to file and sort
############################################################
./GitHubRepoList.sh -o "${org}" -l "${limit}" -f "name"
while IFS= read -r line; do
repo=$(echo "${line}" | tr -d '"')
if [[ $repo == "name" ]]; then
continue
fi
workflows=$(gh api \
-H "Accept: application/vnd.github+json" \
-H "X-GitHub-Api-Version: 2022-11-28" \
/repos/"${org}"/"${repo}"/actions/workflows | jq '.workflows[] | select(.state == "disabled_manually") | .path')
if [ -n "$workflows" ]; then
for workflow_path in $workflows
do
echo "${org}/${repo}/$(echo $workflow_path | tr -d \")"
done
fi
done < repolist.csv
rm repolist.csv