docker-nixpkgs/dockerhub-metadata
Jonas Chevalier bf1338907c
ci: add GitHub Actions cron (#16)
* ci: add dependabot

* ci: revamp logic

Merge username and password as a single auth token. It doesn't make
sense to split out the user and password since they are so tied
together. Might as well treat the whole think as a secret blob.

Remove Travis-CI. Travis is dead for OSS.

Add GitHub Actions cron. Remove cachix as it's pushing too much stuff.

Merge all of the CI logic into a single ci.sh script.
2021-02-10 13:25:01 +01:00

45 lines
1,012 B
Bash
Executable file

#!/usr/bin/env bash
#
# Update docker hub image descriptions. The API is not documented and might
# break in the future.
#
# Usage: ./dockerhub-metadata <user> <password> [org]
set -euo pipefail
user=$1
org=${2:-nixpkgs}
nix_eval() {
nix-instantiate --strict --eval --json "$@"
}
releases_json=$(nix_eval)
to_json() {
local desc=$1 full_desc=$2
jq -n \
--arg desc "$desc" \
--arg full_desc "$full_desc" \
'.description=$desc | .full_description=$full_desc'
}
echo "=== Updating Docker Hub project descriptions"
for attr in $(echo "$releases_json" | jq -r "keys[]") ; do
echo "--- $attr"
desc=$(nix_eval -A "$attr.meta.description" | jq -r .)
if [[ -f "$attr/README.md" ]]; then
full_desc=$(< "$attr/README.md")
else
full_desc=$(< "README.md")
fi
data=$(to_json "$desc" "$full_desc")
echo "data: $data"
url=https://cloud.docker.com/v2/repositories/$org/$attr/
curl -XPATCH -H "Content-Type: application/json" --user "$user" --data "$data" "$url"
done
echo OK