blob: f7313bc37142c86dc30b6b3b5808a280568709c9 (
plain) (
tree)
|
|
#!/usr/bin/env sh
# $BUILDKITE_API_TOKEN must be set.
if [ -z "$BUILDKITE_API_TOKEN" ]; then
echo 'Error: $BUILDKITE_API_TOKEN is empty or not set.' 1>&2
exit 1
fi
BASE_URL=https://api.buildkite.com/v2/organizations/ninenines
_download() {
for f in pipelines/*
do
curl -H "Authorization: Bearer $BUILDKITE_API_TOKEN" \
"$BASE_URL/$f" > $f
done
}
_upload() {
for f in pipelines/*
do
curl -H "Authorization: Bearer $BUILDKITE_API_TOKEN" \
-X PATCH --data-binary @$f "$BASE_URL/$f"
done
}
case "$1" in
download)
_download
;;
upload)
_upload
;;
*)
echo "Unknown command: $1"
exit 1
;;
esac
|