11#! /bin/bash
2+ # =============================================================================
3+ # github-dockerfile-discovery.sh
4+ #
5+ # Searches all organisations in a GitHub Enterprise account for Dockerfiles,
6+ # extracts base image references from FROM instructions, and generates CSV
7+ # reports to identify common base images across the estate.
8+ #
9+ # Usage:
10+ # export GITHUB_TOKEN=ghp_yourtoken
11+ # export ENTERPRISE=my-enterprise
12+ # ./github-dockerfile-discovery.sh
13+ #
14+ # Environment variables:
15+ # GITHUB_TOKEN Required. PAT with read:org and repo scope
16+ # ENTERPRISE Required. GitHub Enterprise slug
17+ # API_URL_PREFIX Optional. GitHub API base URL (default: https://api.github.com)
18+ # REPORT_DIR Optional. Output directory (default: ./reports)
19+ # ORGS Optional. Comma-separated org list; skips enterprise lookup
20+ # ORG_FILTER Optional. ERE regex to keep only matching org names
21+ # ORG_EXCLUDE Optional. ERE regex to drop matching org names
22+ # SEARCH_SLEEP Optional. Seconds between code-search requests (default: 2)
23+ # CONTENT_SLEEP Optional. Seconds between content-fetch requests (default: 1)
24+ #
25+ # Requirements:
26+ # - curl
27+ # - jq
28+ # =============================================================================
29+
230set -euo pipefail
331
432SCRIPT_DIR=" $( cd " $( dirname " ${BASH_SOURCE[0]} " ) " && pwd) "
@@ -10,27 +38,6 @@ print_success() { echo -e "${GREEN}[SUCCESS]${NC} $1" >&2; }
1038print_warning () { echo -e " ${YELLOW} [WARNING]${NC} $1 " >&2 ; }
1139print_error () { echo -e " ${RED} [ERROR]${NC} $1 " >&2 ; }
1240
13- # ##
14- # # GitHub Enterprise Dockerfile Discovery
15- # # Searches all organisations in a GitHub Enterprise account for Dockerfiles,
16- # # extracts base image references from FROM instructions, and generates CSV
17- # # reports to identify common base images across the estate.
18- # #
19- # # Usage:
20- # # export GITHUB_TOKEN=ghp_yourtoken
21- # # export ENTERPRISE=my-enterprise
22- # # ./github-dockerfile-discovery.sh
23- # #
24- # # Optional env vars:
25- # # API_URL_PREFIX - GitHub API base URL (default: https://api.github.com)
26- # # REPORT_DIR - Output directory (default: ./reports)
27- # # ORGS - Comma-separated org list; skips enterprise lookup
28- # # ORG_FILTER - ERE regex to keep only matching org names (e.g. '^my-enterprise-prefix')
29- # # ORG_EXCLUDE - ERE regex to drop matching org names
30- # # SEARCH_SLEEP - Seconds between code-search requests (default: 2)
31- # # CONTENT_SLEEP - Seconds between content-fetch requests (default: 1)
32- # ##
33-
3441# ##
3542# # GLOBAL VARIABLES
3643# ##
0 commit comments