aboutsummaryrefslogtreecommitdiffstats
path: root/pipelines.sh
diff options
context:
space:
mode:
Diffstat (limited to 'pipelines.sh')
-rwxr-xr-xpipelines.sh38
1 files changed, 38 insertions, 0 deletions
diff --git a/pipelines.sh b/pipelines.sh
new file mode 100755
index 0000000..f7313bc
--- /dev/null
+++ b/pipelines.sh
@@ -0,0 +1,38 @@
+#!/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