;; 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 . (define-module (src crawl-actions-wrapper) #:use-module (srfi srfi-1) #:use-module (ice-9 string-fun) #:use-module ((src utils) #:prefix util:) #:use-module ((src config) #:prefix conf:) #:use-module (ice-9 textual-ports) #:use-module ((src poll-repos) #:prefix poll:) #:export (crawl-actions external-file)) (define mapdir (dirname poll:outfile)) (define mapfile (in-vicinity mapdir "repos-to-actions-map.txt")) (define actiondir (in-vicinity conf:cache-dir "actions")) (define external-file (in-vicinity actiondir "external.txt")) (define docker-file (in-vicinity actiondir "docker.txt")) (define file->regex `((,external-file . "^[A-Za-z0-9][A-Za-z0-9_.-]*(/[A-Za-z0-9_.-]+)*(\\s(\\S+))?$") (,docker-file . "^docker://") (,(in-vicinity actiondir "internal.txt") . "^\\./[A-Za-z0-9_./-]+(\\s(\\S+))?$"))) (define (get-uniq-actions str) (define (kill-comments str) (let ((pos (string-index str #\#))) (if pos (substring str 0 pos) str))) (let* ((lines (filter (lambda (s) (not (string=? s ""))) (string-split str #\newline))) (lines (map kill-comments lines)) (actions (map (lambda (l) (cadr (string-split l char-set:whitespace))) lines)) (uniq-actions (delete-duplicates actions))) (map (lambda (a) (string-replace-substring a "@" " ")) uniq-actions))) (define (crawl-actions) (let* ((repos-to-actions-map-sh (in-vicinity conf:scripts-dir "repos_to_actions_map.sh"))) (system (string-append repos-to-actions-map-sh " < " poll:outfile " >> " mapfile))) ;append mode ;; again, we do this separately after writing everything to another file ;; github can cut me off at any time. I would prefer the choice of ;; restarting again with a manually modified input file than lose all data. (util:normalize-file mapfile) (util:filter-actions-on-regex mapfile file->regex get-uniq-actions))