Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove badges from "repo stub readme" contents #2503

Merged
merged 1 commit into from
Nov 21, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
87 changes: 0 additions & 87 deletions generate-repo-stub-readme.sh
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,6 @@ 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/}"

case "$githubRepoName" in
# Elastic points "github-repo" at their upstream elastic/xyz-docker repos, but we want our README stubs to still point at our integration repos
elastic/*) githubRepoName="docker-library/$repo" ;;

hylang/hy) githubRepoName='hylang/docker-hylang' ;;
esac

maintainer="$(sed -e 's!%%GITHUB-REPO%%!'"$canonicalRepo"'!g' "$repo/maintainer.md")"

Expand Down Expand Up @@ -61,85 +53,6 @@ The [full image description on Docker Hub]($hubPage) is generated/maintained ove
For more information about the full official images change lifecycle, see [the "An image's source changed in Git, now what?" FAQ entry](https://github.com/docker-library/faq#an-images-source-changed-in-git-now-what).

For outstanding \`$repo\` image PRs, check [PRs with the "library/$repo" label on the official-images repository](https://github.com/docker-library/official-images/labels/library%2F$repo). For the current "source of truth" for [\`$repo\`]($hubPage), see [the \`library/$repo\` file in the official-images repository](https://github.com/docker-library/official-images/blob/master/library/$repo).
EOREADME

badges=()

n=$'\n'
t=$'\t'

branch='master'
toTest=(
# "image badge URL"
# "image badge link/href"
# "badge test URL (to determine whether badge applies)"

"https://img.shields.io/github/actions/workflow/status/$githubRepoName/ci.yml?branch=$branch&label=GitHub%20CI"
"https://github.com/$githubRepoName/actions?query=workflow%3A%22GitHub+CI%22+branch%3A$branch"
"https://github.com/$githubRepoName/blob/$branch/.github/workflows/ci.yml"

"https://img.shields.io/jenkins/s/https/doi-janky.infosiftr.net/job/update.sh/job/$repo.svg?label=Automated%20update.sh"
"https://doi-janky.infosiftr.net/job/update.sh/job/$repo/"
"https://doi-janky.infosiftr.net/job/update.sh/job/$repo/"
)

_wget_spider() {
wget -q -o /dev/null -O /dev/null --spider "$@"
}

set -- "${toTest[@]}"
while [ "$#" -gt 0 ]; do
image="$1"; shift
url="$1"; shift
testUrl="$1"; shift
if _wget_spider "$testUrl"; 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
jenkinsJob="job/put-shared/job/light/job/$repo"
if ! _wget_spider "https://doi-janky.infosiftr.net/$jenkinsJob/"; then
jenkinsJob='job/put-shared/job/heavy'
fi
else
jenkinsJob="job/multiarch/job/$arch/job/$repo"
fi
jenkinsLink="https://doi-janky.infosiftr.net/$jenkinsJob/"
jenkinsImage="https://img.shields.io/jenkins/s/https/doi-janky.infosiftr.net/$jenkinsJob.svg?label=$arch"
if _wget_spider "$jenkinsLink"; 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

<!-- THIS FILE IS GENERATED BY $gitRepo/blob/master/generate-repo-stub-readme.sh -->
EOREADME