ofborg/scripts/update-known-users.sh

38 lines
1,014 B
Bash
Raw Normal View History

#!/usr/bin/env nix-shell
#!nix-shell -p bash -p jq -p curl -i bash
readonly token=$(jq -r '.github.token' ./config.private.json)
readonly dest=config.known-users.json
readonly scratch=user-list.scratch
readonly accumulator=user-list.accumulator
readonly result=user-list.result
function fetch_users() {
curl \
-H "Authorization: token $token" \
"https://api.github.com/orgs/NixOS/members?page=$1" \
| jq 'map(.login | ascii_downcase)'
}
2018-01-28 13:21:18 +00:00
cp ./config.extra-known-users.json "$accumulator"
page=0
while true; do
page=$((page + 1))
fetch_users "$page" > "$scratch"
2018-01-28 13:21:18 +00:00
jq -s '.[0] + .[1] | sort' "$accumulator" "$scratch" > "$result"
mv "$result" "$accumulator"
if [ $(jq -r 'length' "$scratch") -eq 0 ]; then
break
fi
done
jq -s '{ "runner": { "known_users": .[0]}}' "$accumulator" > "$dest"
rm -f "$result" "$scratch" "$accumulator"
2018-02-23 22:10:56 +00:00
jq -s '.[0] * .[1] * .[2]' ./config.public.json ./config.known-users.json ./config.private.json > ./config.prod.json