blob: 2216a5ab7a4112a45f96ffaab9a79a851f7d526c (
plain)
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
|
#!/usr/bin/env bash
# kenku --- crawl and reproduce github actions
# Copyright © 2026 bdunahu <bdunahu@operationnull.com>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
#
# Takes a file with one repo per line and outputs a master list
# of REPO, ACTION pairs. This script takes a long time to run.
# There is an obvious part of this script that is pretty gross.
# I got it working sometime in early march and have forgotten
# why it does what it does.
function get_flows {
curl -s \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer $TOKEN" \
"https://api.github.com/repos/$1/$2/contents/.github/workflows"
}
function has_flows {
echo "$1" \
| jq -e 'type == "object" and has("message") | not' >/dev/null 2>&1
}
function get_url {
local owner repo flows
owner=$(echo "$1" | awk -F'/' '{print $(NF-1)}')
repo=$(echo "$1" | awk -F'/' '{print $(NF)}')
flows=$(get_flows "$owner" "$repo")
has_flows "$flows" &&
echo "$flows" | jq -r '.[] | select(.type=="file") | .download_url' \
| xargs -n1 sh -c '
for url do
curl -s "$url" | grep -E "^\s*-?\s*uses:" | sed "s|.*uses:\s*|$1 |"
done
' _ "$1" # passes arg to sh -c
}
while read -r url; do
get_url "$url"
done
|