forked from nix-community/docker-nixpkgs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
dockerhub-metadata
executable file
·45 lines (35 loc) · 1012 Bytes
/
dockerhub-metadata
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#!/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