diff --git a/generate-repo-stub-readme.sh b/generate-repo-stub-readme.sh index d9a686725..a103ee428 100755 --- a/generate-repo-stub-readme.sh +++ b/generate-repo-stub-readme.sh @@ -19,7 +19,11 @@ fi gitRepo='https://github.com/docker-library/docs' hubPage="https://registry.hub.docker.com/_/$repo/" -canonicalRepo="$(curl -fsSLI -o /dev/null -w '%{url_effective}\n' "https://github.com/docker-library/$repo")" # follow redirects (http://stackoverflow.com/a/3077316/433558) +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) travisRepo="${canonicalRepo#*://github.com/}" cat < +EOREADME + +badges=() + +n=$'\n' +t=$'\t' + +travisImage="https://img.shields.io/travis/$travisRepo/master.svg" +if wget -q --spider "$travisImage" &> /dev/null; then + travisLink="https://travis-ci.org/$travisRepo/branches" + badges+=( "-${t}[Travis CI: ${n}${t}![build status badge]($travisImage)]($travisLink)" ) +fi + +jenkinsImage="https://doi-janky.infosiftr.net/job/update.sh/job/$repo/badge/icon" +if wget -q --spider "$jenkinsImage" &> /dev/null; then + jenkinsLink="https://doi-janky.infosiftr.net/job/update.sh/job/$repo" + badges+=( "-${t}[Automated \`update.sh\`: ${n}${t}![build status badge]($jenkinsImage)]($jenkinsLink)" ) +fi + +if [ "${#badges[@]}" -gt 0 ]; then + IFS=$'\n' + cat <<-EOREADME + + --- + + ${badges[*]} + EOREADME + unset IFS +fi + +cat < EOREADME