From 9e143d1d84817ec7e6d139d234f0fff07749621c Mon Sep 17 00:00:00 2001 From: bdunahu Date: Mon, 27 Apr 2026 22:16:12 -0400 Subject: initial commit --- src/scripts/repos_to_actions_map.sh | 53 +++++++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100755 src/scripts/repos_to_actions_map.sh (limited to 'src/scripts/repos_to_actions_map.sh') diff --git a/src/scripts/repos_to_actions_map.sh b/src/scripts/repos_to_actions_map.sh new file mode 100755 index 0000000..2216a5a --- /dev/null +++ b/src/scripts/repos_to_actions_map.sh @@ -0,0 +1,53 @@ +#!/usr/bin/env bash +# kenku --- crawl and reproduce github actions +# Copyright © 2026 bdunahu +# +# 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 . +# +# 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 -- cgit v1.2.3