#!/usr/bin/env bash set -Eeuo pipefail cd "$(dirname "$(readlink -f "$BASH_SOURCE")")" repo="${1:-}" if [ -z "$repo" ]; then echo >&2 'error: no repo specified' cat >&2 < README.md] ie: $0 php > ../php/README.md This script generates a stub README to standard out for the specified repo. EOUSAGE exit 1 fi gitRepo='https://github.com/docker-library/docs' hubPage="https://hub.docker.com/_/$repo/" canonicalRepo="https://github.com/docker-library/$repo" if [ -s "$repo/github-repo" ]; then canonicalRepo="$(< "$repo/github-repo")" fi canonicalRepo="$(curl -fsSLI -o /dev/null -w '%{url_effective}\n' "$canonicalRepo")" # follow redirects (http://stackoverflow.com/a/3077316/433558) githubRepoName="${canonicalRepo#*://github.com/}" if [[ "$githubRepoName" = elastic/* ]]; then # Elastic points "github-repo" at their upstream elastic/xyz-docker repos, but we want our README stubs to still point at our integration repos githubRepoName="docker-library/$repo" fi maintainer="$(sed -e 's!%%GITHUB-REPO%%!'"$canonicalRepo"'!g' "$repo/maintainer.md")" if [ -f "$repo/deprecated.md" ]; then echo '# DEPRECATED' echo cat "$repo/deprecated.md" echo fi cat </dev/null \ | grep -qvE 'unknown|invalid|access denied|not found' } set -- "${toTest[@]}" while [ "$#" -gt 0 ]; do image="$1"; shift url="$1"; shift if _check_shields_io_image "$image"; then badges+=( "-${t}[![build status badge]($image)]($url)" ) fi done arches="$(bashbrew cat --format '{{ range .Entries }}{{ join "\n" .Architectures }}{{ "\n" }}{{ end }}' "https://github.com/docker-library/official-images/raw/master/library/$repo" | sort -u)" if [ -n "$arches" ]; then archTable= i=0 for arch in $arches put-shared; do if [ "$arch" = 'put-shared' ]; then jenkinsLink= for jenkinsJob in "job/put-shared/job/light/job/$repo" 'job/put-shared/job/heavy'; do jenkinsImage="https://img.shields.io/jenkins/s/https/doi-janky.infosiftr.net/$jenkinsJob.svg?label=$arch" if _check_shields_io_image "$jenkinsImage"; then jenkinsLink="https://doi-janky.infosiftr.net/$jenkinsJob/" break fi done if [ -z "$jenkinsLink" ]; then continue fi else jenkinsLink="https://doi-janky.infosiftr.net/job/multiarch/job/$arch/job/$repo/" jenkinsImage="https://img.shields.io/jenkins/s/https/doi-janky.infosiftr.net/job/multiarch/job/$arch/job/$repo.svg?label=$arch" fi if _check_shields_io_image "$jenkinsImage"; then archTable="${archTable:-|} [![$arch build status badge]($jenkinsImage)]($jenkinsLink) |" (( i = (i + 1) % 4 )) || : # modulo here needs to match the number of colums used below if [ "$i" = 0 ]; then archTable+="${n}|" fi fi done if [ -n "$archTable" ]; then if [ "${#badges[@]}" -gt 0 ]; then badges+=( '' ) fi badges+=( "| Build | Status | Badges | (per-arch) |${n}|:-:|:-:|:-:|:-:|${n}${archTable%${n}|}" ) fi fi if [ "${#badges[@]}" -gt 0 ]; then IFS=$'\n' cat <<-EOREADME --- ${badges[*]} EOREADME unset IFS fi cat < EOREADME