-
-
Notifications
You must be signed in to change notification settings - Fork 10
/
buildkite.sh
executable file
·36 lines (31 loc) · 968 Bytes
/
buildkite.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
#!/usr/bin/env nix-shell
#!nix-shell -i bash ./shell.nix
set -eu
set -o pipefail
cfgOpt() {
touch build.cfg
ret=$(awk '$1 == "'"$1"'" { print $2; }' build.cfg)
if [ -z "$ret" ]; then
echo "Config option '$1' isn't specified in build.cfg" >&2
echo "Example format:"
echo "$1 value"
echo ""
exit 1
fi
echo "$ret"
}
if [ "${PACKET_AUTH_TOKEN:-x}" == "x" ]; then
PACKET_AUTH_TOKEN=$(cfgOpt "packetKey")
fi
if [ "${PACKET_PROJECT_ID:-x}" == "x" ]; then
PACKET_PROJECT_ID=$(cfgOpt "packetProjectId")
fi
curl \
--header 'Accept: application/json' \
--header 'Content-Type: application/json' \
--header "X-Auth-Token: $PACKET_AUTH_TOKEN" \
--fail \
"https://api.packet.net/projects/${PACKET_PROJECT_ID}/devices?per_page=1000" \
| jq . > ./devices.json
nix-instantiate -I nixpkgs=channel:nixos-unstable-small \
--eval --strict --json ./buildkite.nix | jq .