-
Notifications
You must be signed in to change notification settings - Fork 0
/
generate.sh
executable file
·40 lines (34 loc) · 1.43 KB
/
generate.sh
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
#!/bin/bash
set -e
function get() {
curl -s -X GET -H "Content-Type: application/json" \
-H "Authorization: Bearer ${DO_TOKEN}" \
"https://api.digitalocean.com/v2/$1?page=1&per_page=10000" \
| jq -S -e '.' > "$2"
}
function simple() {
printf "$1$2\n" >> README.md && \
printf '````yaml\n' >> README.md && \
jq -S -e "$2" "$1" | sed 's/\"//g' >> README.md && \
printf '````\n' >> README.md
}
get "images" "images.json"
get "sizes" "sizes.json"
get "regions" "regions.json"
get "kubernetes/options" "kubernetes.json"
rm README.md || true
printf "https://bukowa.github.io/digitalocean-images/\n\n" >> README.md
printf "Referral \$200 link\n\n" >> README.md
echo '<a href="https://www.digitalocean.com/?refcode=97c5fc2f1bd1&utm_campaign=Referral_Invite&utm_medium=Referral_Program&utm_source=badge"><img src="https://web-platforms.sfo2.cdn.digitaloceanspaces.com/WWW/Badge%201.svg" alt="DigitalOcean Referral Badge" /></a>' >> README.md
printf "\n\n" >> README.md
printf "[images](./images.json) ||| " >> README.md
printf "[sizes](./sizes.json) ||| " >> README.md
printf "[regions](./regions.json) |||\n\n" >> README.md
printf "[kubernetes](./kubernetes.json)\n\n" >> README.md
simple "images.json" ".images[].slug"
simple "sizes.json" ".sizes[].slug"
simple "regions.json" ".regions[].slug"
simple "kubernetes.json" ".options.versions[].kubernetes_version"
#simple "images.json" "."
#simple "sizes.json" "."
#simple "regions.json" "."