generate-repo-stub-readme.sh 3.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. #!/bin/bash
  2. set -e
  3. cd "$(dirname "$(readlink -f "$BASH_SOURCE")")"
  4. repo="$1"
  5. if [ -z "$repo" ]; then
  6. echo >&2 'error: no repo specified'
  7. cat >&2 <<EOUSAGE
  8. usage: $0 repo [> README.md]
  9. ie: $0 php > ../php/README.md
  10. This script generates a stub README to standard out for the specified repo.
  11. EOUSAGE
  12. exit 1
  13. fi
  14. gitRepo='https://github.com/docker-library/docs'
  15. hubPage="https://hub.docker.com/_/$repo/"
  16. canonicalRepo="https://github.com/docker-library/$repo"
  17. if [ -s "$repo/github-repo" ]; then
  18. canonicalRepo="$(< "$repo/github-repo")"
  19. fi
  20. canonicalRepo="$(curl -fsSLI -o /dev/null -w '%{url_effective}\n' "$canonicalRepo")" # follow redirects (http://stackoverflow.com/a/3077316/433558)
  21. travisRepo="${canonicalRepo#*://github.com/}"
  22. maintainer="$(sed -e 's!%%GITHUB-REPO%%!'"$canonicalRepo"'!g' "$repo/maintainer.md")"
  23. if [ -f "$repo/deprecated.md" ]; then
  24. echo '# DEPRECATED'
  25. echo
  26. cat "$repo/deprecated.md"
  27. echo
  28. fi
  29. cat <<EOREADME
  30. # $canonicalRepo
  31. ## Maintained by: $maintainer
  32. This is the Git repo of the [Docker "Official Image"](https://docs.docker.com/docker-hub/official_repos/) for [$repo]($hubPage) (not to be confused with any official $repo image provided by $repo upstream). See [the Docker Hub page]($hubPage) for the full readme on how to use this Docker image and for information regarding contributing and issues.
  33. The [full description from Docker Hub]($hubPage) is generated over in [docker-library/docs]($gitRepo), specifically in [docker-library/docs/$repo]($gitRepo/tree/master/$repo).
  34. ## See a change merged here that doesn't show up on Docker Hub yet?
  35. Check [the "library/$repo" manifest file in the docker-library/official-images repo](https://github.com/docker-library/official-images/blob/master/library/$repo), especially [PRs with the "library/$repo" label on that repo](https://github.com/docker-library/official-images/labels/library%2F$repo).
  36. For more information about the official images process, see the [docker-library/official-images readme](https://github.com/docker-library/official-images/blob/master/README.md).
  37. EOREADME
  38. badges=()
  39. n=$'\n'
  40. t=$'\t'
  41. travisImage="https://img.shields.io/travis/$travisRepo/master.svg"
  42. if svg="$(wget -qO- "$travisImage" 2>/dev/null)" && [[ "$svg" != *unknown* ]]; then
  43. travisLink="https://travis-ci.org/$travisRepo/branches"
  44. badges+=( "-${t}[Travis CI: ${n}${t}![build status badge]($travisImage)]($travisLink)" )
  45. fi
  46. # https://www.appveyor.com/docs/status-badges/#badges-for-projects-with-public-repositories-on-github-and-bitbucket
  47. appveyorImage="https://ci.appveyor.com/api/projects/status/github/docker-library/$repo?branch=master&svg=true"
  48. if svg="$(wget -qO- "$appveyorImage" 2>/dev/null)" && [[ "$svg" != *unknown* ]]; then
  49. appveyorLink="https://ci.appveyor.com/project/docker-library/$repo"
  50. badges+=( "-${t}[AppVeyor (Windows): ${n}${t}![build status badge]($appveyorImage)]($appveyorLink)" )
  51. fi
  52. jenkinsImage="https://doi-janky.infosiftr.net/job/update.sh/job/$repo/badge/icon"
  53. if wget -q --spider "$jenkinsImage" &> /dev/null; then
  54. jenkinsLink="https://doi-janky.infosiftr.net/job/update.sh/job/$repo"
  55. badges+=( "-${t}[Automated \`update.sh\`: ${n}${t}![build status badge]($jenkinsImage)]($jenkinsLink)" )
  56. fi
  57. if [ "${#badges[@]}" -gt 0 ]; then
  58. IFS=$'\n'
  59. cat <<-EOREADME
  60. ---
  61. ${badges[*]}
  62. EOREADME
  63. unset IFS
  64. fi
  65. cat <<EOREADME
  66. <!-- THIS FILE IS GENERATED BY $gitRepo/blob/master/generate-repo-stub-readme.sh -->
  67. EOREADME